From 3231d1062d0930a9344dd8550243331696ca27eb Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Wed, 9 Sep 2026 19:29:09 +0000 Subject: vyos.utils: T9269: no zero-component key path for an empty dict dict_to_key_paths() yields the path leading to an empty dict, which is a valueless leaf node. An empty dict at the top level means "no configuration" and yielded a single zero-component path, making dict_to_paths_values() report an option named ''. A bare "interfaces ethernet eth1" - as found in a container, where no hw-id is deployed - could therefore not be added to a bond: Cannot add interface "eth1" to bond, it has a "" assigned! interfaces_ethernet.py recorded the same phantom path in bond_blocked_changes. configdiff.py was immune, owner([]) is falsy. --- python/vyos/utils/dict.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/vyos/utils/dict.py b/python/vyos/utils/dict.py index 3fcda902f..058717265 100644 --- a/python/vyos/utils/dict.py +++ b/python/vyos/utils/dict.py @@ -315,7 +315,12 @@ def dict_to_key_paths(d: dict) -> list: """ def func(d, path): if isinstance(d, dict): - if not d: + # An empty dict is a valueless leaf node and yields the path that + # leads to it - but only if there is one. An empty dict at the top + # level means "no configuration at all", which must yield nothing + # instead of a single empty path: consumers join the components + # into a dotted option name, and '' is not an option + if not d and path: yield path for k, v in d.items(): for r in func(v, path + [k]): -- cgit v1.2.3