diff options
author | John Estabrook <jestabro@vyos.io> | 2022-10-20 16:25:51 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-10-20 16:25:51 -0500 |
commit | 40cf5f7c1b8d8ae27b5c404807294f8a2a76842d (patch) | |
tree | 2666d714b496f6616d81188813100c259aeb44fc /python/vyos/opmode.py | |
parent | 66fb698a106ed56677fdaaef1a934d0ea7b96561 (diff) | |
download | vyos-1x-40cf5f7c1b8d8ae27b5c404807294f8a2a76842d.tar.gz vyos-1x-40cf5f7c1b8d8ae27b5c404807294f8a2a76842d.zip |
T4765: normalize fields only if 'raw' is true; output must be dict
Diffstat (limited to 'python/vyos/opmode.py')
-rw-r--r-- | python/vyos/opmode.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py index ac9c0c353..5f9c2c1ce 100644 --- a/python/vyos/opmode.py +++ b/python/vyos/opmode.py @@ -185,10 +185,12 @@ def run(module): # they may return human-formatted output # or a raw dict that we need to serialize in JSON for printing res = func(**args) - res = _normalize_field_names(res) if not args["raw"]: return res else: + if not isinstance(res, dict): + raise InternalError("'raw' output of 'show_*' command must be a dict") + res = _normalize_field_names(res) from json import dumps return dumps(res, indent=4) else: |