Page MenuHomeVyOS Platform

Malformed lines cause vyos.util.colon_separated_to_dict fail with a nondescript error
Closed, ResolvedPublic

Description

If you try to parse strings that don't follow the expected "colon-separated pair on every non-empty line" format with vyos.util.colon_separated_to_dict(), you get a non-informative unassigned variable error that doesn't provide any insight into the cause or debugging hints.

>>> import vyos.util
>>> vyos.util.colon_separated_to_dict("no colon in this line, lmao")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/vyos/util.py", line 334, in colon_separated_to_dict
    if key in data.keys():
UnboundLocalError: local variable 'key' referenced before assignment

I believe such errors should explain what happened and show the offending line.

Details

Version
-
Is it a breaking change?
Perfectly compatible
Issue type
Internal change (not visible to end users)

Event Timeline

Viacheslav moved this task from Open to Finished on the VyOS 1.4 Sagitta board.