Page MenuHomeVyOS Platform

Enhancements/bugfixes for vyos_dict_search()
Closed, ResolvedPublicBUG

Description

vyos.util.vyos_dict_search(path, dict) is a lightweight alternative to jmespath.search() which will traverse a dictionary given on a dot separated path.

KeyError

If we only supply path = 'foo' and 'foo' is not a key within the passed dict a KeyError will be generated:

>>> data = {}
>>> vyos_dict_search('foo', data)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/vyos/util.py", line 685, in vyos_dict_search
    return dict[path]
KeyError: 'foo'

This is most likely not what we have intended for the use of vyos_dict_search(), we rather would see retunring it None or [] - which is yet to be decided.

Add Unittests to vyos-1x builds

As this is a crucial part of the internal API, UnitTests must be supplied.

Details

Difficulty level
Easy (less than an hour)
Version
1.3-rolling-202010180826
Why the issue appeared?
Other
Is it a breaking change?
Perfectly compatible
Issue type
Internal change (not visible to end users)

Event Timeline

c-po changed the task status from Open to In progress.Oct 19 2020, 10:04 AM
c-po claimed this task.
c-po triaged this task as High priority.
c-po updated the task description. (Show Details)
c-po changed Why the issue appeared? from Will be filled on close to Other.
c-po changed Is it a breaking change? from Unspecified (possibly destroys the router) to Perfectly compatible.
c-po updated the task description. (Show Details)
erkin set Issue type to Internal change (not visible to end users).Aug 29 2021, 12:33 PM
erkin removed a subscriber: Active contributors.