Page MenuHomeVyOS Platform

conf.get_config_dict() throws exception
Closed, ResolvedPublicBUG

Description

vyos@vyos# show interfaces wirelessmodem
 wirelessmodem wlm10 {
+    backup {
+    }
>    description foo
+    device ttyUSB0
+    disable-link-detect
 }
[edit]
vyos@vyos# commit
[ interfaces wirelessmodem wlm10 ]
Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/interfaces-wirelessmodem.py", line 77, in <module>
    c = get_config()
  File "/usr/libexec/vyos/conf_mode/interfaces-wirelessmodem.py", line 50, in get_config
    tmp = conf.get_config_dict()
  File "/usr/lib/python3/dist-packages/vyos/config.py", line 254, in get_config_dict
    config_tree = vyos.configtree.ConfigTree(res)
  File "/usr/lib/python3/dist-packages/vyos/configtree.py", line 182, in __init__
    raise ValueError("Failed to parse config: {0}".format(msg))
ValueError: Failed to parse config: Syntax error on line 2, character 2: Invalid syntax.

[[interfaces wirelessmodem wlm10]] failed
Commit failed

Code to reproduce: https://github.com/c-po/vyos-1x/commit/dd4b310db0c5e368f99c3490f9e39f85e681ea95
Binary: https://helix.mybll.net/vyos-1x_1.3.0-16_all.deb

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.3-rolling-202001251111
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

c-po created this task.
c-po updated the task description. (Show Details)

As expected,
(1) This is a parser error
(2) It is independent of any specific configuration script; it can be reproduced by calling conf.get_config_dict() with uncommitted changes, from any conf_mode script.

The issue arises when passing config changes, with the initial annotations '+'/'-' to configtree; it will pass in some very limited cases, but fail in general.

Further analysis is needed to understand the parser error. However, accommodating this case in the parser is not 'incorrect' behaviour, as those symbols are not a part of the config grammar. Consequently, we need to consider use cases and/or implementation of get_config_dict() .... in progress

Actually, upon reflection, the parser error is just too many terms on the line, hitting HandlingError; the rare exception exists, but is misleading, so 'use cases and/or implementation' ...

erkin set Issue type to Bug (incorrect behavior).Aug 31 2021, 5:50 PM