Skip to content

Commit

Permalink
config: T5228: fix key shift in merge_defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
jestabro committed May 22, 2023
1 parent c0f8e73 commit 73820e1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions python/vyos/xml_ref/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,20 @@ def merge_defaults(self, path: list, conf: dict) -> dict:
This merges non-recursive defaults relative to the config dict.
"""
if path[-1] in list(conf):
config = conf[path[-1]]
if not isinstance(config, dict):
if not path:
shift = False
elif path[-1] in list(conf):
conf = conf[path[-1]]
if not isinstance(conf, dict):
raise TypeError('conf at path is not of type dict')
shift = False
else:
config = conf
shift = True

if not self._well_defined(path, config):
if not self._well_defined(path, conf):
print('path to config dict does not define config paths; conf returned unchanged')
return conf

d = self.relative_defaults(path, conf=config, get_first_key=shift)
d = self.relative_defaults(path, conf=conf, get_first_key=shift)
d = dict_merge(d, conf)
return d

0 comments on commit 73820e1

Please sign in to comment.