# Buggy code
def _merge_defaults(self, cfg, defaults, split_at):
    def get_filename(config_name):
        filename, ext = os.path.splitext(config_name)
        if ext == "":
            ext = ".yaml"
        return "{}{}".format(filename, ext)

    def merge_defaults(merged_cfg, def_list):
        cfg_with_list = OmegaConf.create(dict(defaults=def_list))
        for default1 in cfg_with_list.defaults:
            if isinstance(default1, DictConfig):
                is_optional = False
                if default1.optional is not None:
                    is_optional = default1.optional
                    del default1["optional"]
                family = next(iter(default1.keys()))
                name = default1[family]
                # Name is none if default value is removed
                if name is not None and "_SKIP_" not in name:
                    merged_cfg = self._merge_config(
                        cfg=merged_cfg,
                        family=family,
                        name=get_filename(name),
                        required=not is_optional,
                    )
            else:
                assert isinstance(default1, str)
                if "_SKIP_" not in default1:
                    merged_cfg = self._merge_config(
                        cfg=merged_cfg,
                        family="",
                        name=get_filename(default1),
                        required=True,
                    )
        return merged_cfg

    system_list = []
    user_list = []
    for default in defaults:
        if len(system_list) < split_at:
            system_list.append(default)
        else:
            user_list.append(default)
    cfg = merge_defaults(cfg, system_list)
    cfg = merge_defaults(cfg, user_list)

    if "defaults" in cfg:
        del cfg["defaults"]
    return cfg


# Traceback (hydra.errors.MissingConfigException)
Traceback (most recent call last):
File "app.py", line 9, in <module>
app()
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/main.py", line 24, in decorated_main
strict=strict,
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/utils.py", line 56, in run_hydra
hydra.run(overrides=args.overrides)
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 103, in run
cfg = self._load_config(overrides)
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 345, in _load_config
cfg = self.config_loader.load_configuration(overrides)
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/config_loader.py", line 56, in load_configuration
cfg = self._merge_defaults(hydra_cfg, defaults, split_at)
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/config_loader.py", line 395, in _merge_defaults
cfg = merge_defaults(cfg, user_list)
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/config_loader.py", line 374, in merge_defaults
required=not is_optional,
File "/home/yjxiao/miniconda3/lib/python3.7/site-packages/hydra/_internal/config_loader.py", line 301, in _merge_config
raise MissingConfigException(msg, new_cfg, options)
hydra.errors.MissingConfigException: Could not load lr/0.1, available options:
lr:
0.01
0.1

# Fixed code
def _merge_defaults(self, cfg, defaults, split_at):
    def get_filename(config_name):
        filename, ext = os.path.splitext(config_name)
        if ext not in (".yaml", ".yml"):
            config_name = "{}{}".format(config_name, ".yaml")
        return config_name

    def merge_defaults(merged_cfg, def_list):
        cfg_with_list = OmegaConf.create(dict(defaults=def_list))
        for default1 in cfg_with_list.defaults:
            if isinstance(default1, DictConfig):
                is_optional = False
                if default1.optional is not None:
                    is_optional = default1.optional
                    del default1["optional"]
                family = next(iter(default1.keys()))
                name = default1[family]
                # Name is none if default value is removed
                if name is not None and "_SKIP_" not in name:
                    merged_cfg = self._merge_config(
                        cfg=merged_cfg,
                        family=family,
                        name=get_filename(name),
                        required=not is_optional,
                    )
            else:
                assert isinstance(default1, str)
                if "_SKIP_" not in default1:
                    merged_cfg = self._merge_config(
                        cfg=merged_cfg,
                        family="",
                        name=get_filename(default1),
                        required=True,
                    )
        return merged_cfg

    system_list = []
    user_list = []
    for default in defaults:
        if len(system_list) < split_at:
            system_list.append(default)
        else:
            user_list.append(default)
    cfg = merge_defaults(cfg, system_list)
    cfg = merge_defaults(cfg, user_list)

    if "defaults" in cfg:
        del cfg["defaults"]
    return cfg