Page MenuHomeVyOS Platform

get_config_dict is failing when the configuration section is empty/missing
Closed, ResolvedPublicBUG


in order to safely call get_config_dict, config.exists or config.exists_effective need to be called beforehand.

The reason is that the underlying command run will return "Configuration under specified path is empty\n" when the configuration does not exist.
Ideally, this "barrier" call should not be required and the code should be able to detect that failure.

it was suggested that cli-shell-api could provide an error code when the section is missing allowing to detect it occurred.


Difficulty level
Easy (less than an hour)
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Internal change (not visible to end users)

Related Objects

Event Timeline

>>> from vyos.config import Config
>>> conf = Config()
>>> conf.get_config_dict(['service', 'ssh'])
{'ssh': {'disable-host-validation': {}, 'port': ['22']}}
>>> conf.get_config_dict(['service', 'non-existing'])

get_config_dict() retuns an empty dict if path in CLI does not exist. Tested on 1.3.0-rc5 and current

c-po assigned this task to jestabro.
erkin set Issue type to Internal change (not visible to end users).Aug 31 2021, 5:43 PM