From 3d686f3922c204ce3d0793f62bc9eb4a10c23805 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 30 Jul 2025 20:01:59 +0100 Subject: op-mode: T7669: fail op mode cache generation if there are untranslated variables since that means the command is malformed --- python/vyos/xml_ref/generate_op_cache.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'python') diff --git a/python/vyos/xml_ref/generate_op_cache.py b/python/vyos/xml_ref/generate_op_cache.py index e985e8d6b..7f0bbf115 100755 --- a/python/vyos/xml_ref/generate_op_cache.py +++ b/python/vyos/xml_ref/generate_op_cache.py @@ -88,6 +88,14 @@ def translate_position(s: str, pos: list[str]) -> str: def translate_command(s: str, pos: list[str]) -> str: s = translate_exec(s) s = translate_position(s, pos) + + # If there are any untranslated occurences of '_place_holder_", + # it means the command is incorrect, + # e.g., it references "$6" when it only has five words. + if re.search(r'_place_holder_', s): + print(f"Command translation failed: {s}") + sys.exit(1) + return s -- cgit v1.2.3