From 40cf5f7c1b8d8ae27b5c404807294f8a2a76842d Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Thu, 20 Oct 2022 16:25:51 -0500 Subject: T4765: normalize fields only if 'raw' is true; output must be dict --- python/vyos/opmode.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: -- cgit v1.2.3