Page MenuHomePhabricator

libvyosconfig parser cannot handle top level leaf and tag nodes
Closed, ResolvedPublicBUG

Description

In config mode, if I execute command "run show configuration commands" from the top level of the config, I get the the commands for the complete config.

But when I execute the same command from some other level in the config, instead of getting the commands for that particular level, I get the error message :

Could not parse the config file: Failed to parse config: Parse error

And sometime it gets even more specific :

Could not parse the config file: Invalid syntax at character 40: invalid character g

for example.

Details

Difficulty level
Normal (likely a few hours)
Version
1.2.0RC11
Why the issue appeared?
Implementation mistake
jmlccdmd created this task.Jan 22 2019, 3:55 PM
jmlccdmd renamed this task from I config mode command "run show configuration commands" generates an error if not on the top level of the config. to I config mode command "run show configuration commands" generates an error if not on the top level in config mode.Jan 22 2019, 7:41 PM
jmlccdmd renamed this task from I config mode command "run show configuration commands" generates an error if not on the top level in config mode to Command "run show configuration commands" generates an error if not on the top level in config mode.
hagbard claimed this task.Jan 22 2019, 10:38 PM
hagbard changed the task status from Open to Confirmed.
hagbard added a comment.EditedJan 22 2019, 10:45 PM

Issue sits somewhere in vyos.configtree

/usr/lib/python3/dist-packages/vyos/configtree.py line 157

@dmbaturin I could need your help here.

syncer triaged this task as Normal priority.Jan 23 2019, 12:19 AM

I suppose I can port the fix for |commands to it.

I had to pass on libvyos and OCAML, just reading and understanding a few lines took me forever. What would be the fix?

pasik added a subscriber: pasik.Jan 23 2019, 10:25 AM
hagbard reassigned this task from hagbard to dmbaturin.Jan 23 2019, 8:08 PM
hagbard added a subscriber: hagbard.
dmbaturin renamed this task from Command "run show configuration commands" generates an error if not on the top level in config mode to libvyosconfig parser cannot handle top level leaf and tag nodes.Jan 26 2019, 12:03 AM
dmbaturin changed Difficulty level from Unknown (require assessment) to Normal (likely a few hours).
dmbaturin changed Why the issue appeared? from Will be filled on close to Implementation mistake.
dmbaturin changed the task status from Confirmed to Needs testing.Jan 26 2019, 1:04 AM

This issue uncovered more. The parser was written under an assumption that "bare" leaf and tag nodes at the top level are not allowed. In fact, while VyOS config never have them, it's by convention rather than by design, if you create a command definition for one (set foo bar), it works just fine. So, to be consistent with the original parser, the new parser should allow them.
I've removed the restriction on the grammar to allow them (see https://github.com/vyos/libvyosconfig/commit/1dd05b330f3adfe828ba3ca4c71db2e12b8968f6), and now run show configuration commands seems to work with "partial" configs just fine. The change appears to have no ill effects on parsing "normal" config, according to my testing.

That change also allowed me to get rid of the fixup that original commands pipe used. Now both run show configuration commands and the |commands pipe use the same script, /bin/vyos-config-to-commands.

Nice! I will test it tomorrow for sure.

Still same issue on 1.2.0-rolling+201901250337.

conf
edit interfaces
run sh config comm
Could not parse the config file: Failed to parse config: Parse error

libvyosconfig0 v. 0.0.4 but your changelog in github says 0.0.6 so I think there is the issue.

Where do you build the package, I couldn't find it in ci.

hagbard claimed this task.Jan 26 2019, 5:26 PM

Dev.packages has 0.0.06, so something goes sideways during build process, I will work on that and test. I'll take the task back and close it when resolved in ci (looking into it right now). I manually installed the package and everything works as expected.

Rebuilding iso, once it finished it will have the correct version.
[...]
Get:152 http://dev.packages.vyos.net/repositories/current/vyos/ current/main libvyosconfig0 amd64 0.0.6 [841 kB]
[...]
Will test it from the iso, just for peace of mind.

hagbard closed this task as Resolved.Jan 26 2019, 6:34 PM

I confirm that in yesterday's rolling image, the problem is corrected.

Thank you!