From 4d3ca5103c7077bacf01c7fb0a4a680ac5775d48 Mon Sep 17 00:00:00 2001 From: charles-ycg <360143717+charles-ycg@users.noreply.github.com> Date: Thu, 3 Dec 2026 10:34:57 +0800 Subject: [PATCH 1/3] fix(cli): reject malformed extra body in direct verifier --- verify.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/verify.py b/verify.py index 1236a2e..627a06a 100644 --- a/verify.py +++ b/verify.py @@ -656,8 +656,7 @@ async def main(): try: extra_body = json.loads(args.extra_body) except json.JSONDecodeError as e: - logger.error(f"Invalid JSON for --extra-body: {e}") - return + parser.error(f"Invalid JSON for --extra-body: {e.msg}") # M3 models need a generous max_tokens — defaults around 2048 cause # `finish_reason=length` truncation that silently tanks ToolCalls-Match-Rate. From 787fd6cc5edf846738aefbd8063b5f9c5455de0d Mon Sep 17 00:00:00 2001 From: charles-ycg <360143717+charles-ycg@users.noreply.github.com> Date: Thu, 3 Dec 2026 10:35:03 +0800 Subject: [PATCH 2/3] fix(cli): reject malformed extra body in batch verifier --- scripts/batch_verify.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/batch_verify.py b/scripts/batch_verify.py index bf1a8d4..5677b15 100644 --- a/scripts/batch_verify.py +++ b/scripts/batch_verify.py @@ -330,8 +330,7 @@ async def main(): extra_body = json.loads(args.extra_body) logger.info(f"Using extra_body: {extra_body}") except json.JSONDecodeError as e: - logger.error(f"Invalid JSON for --extra-body: {e}") - return + parser.error(f"Invalid JSON for --extra-body: {e.msg}") await batch_verify_providers( provider_file=args.provider_file, From 7fdff0537f2ef1971665811703db95bb96026b46 Mon Sep 17 00:00:00 2001 From: charles-ycg <360143717+charles-ycg@users.noreply.github.com> Date: Thu, 3 Dec 2026 10:35:09 +0800 Subject: [PATCH 3/3] test(cli): cover malformed extra body exit status --- tests/test_extra_body_cli.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_extra_body_cli.py diff --git a/tests/test_extra_body_cli.py b/tests/test_extra_body_cli.py new file mode 100644 index 0000000..49f7b3d --- /dev/null +++ b/tests/test_extra_body_cli.py @@ -0,0 +1,29 @@ +import os +from pathlib import Path +import subprocess +import sys +import unittest + + +ROOT = Path(__file__).resolve().parents[1] + + +class ExtraBodyCliTest(unittest.TestCase): + def test_malformed_extra_body_is_a_usage_error(self): + env = dict(os.environ, PYTHONPATH=os.pathsep.join( + filter(None, (str(ROOT), os.environ.get("PYTHONPATH"))) + )) + commands = ( + ["verify.py", "unused.jsonl", "--model", "test-model", + "--base-url", "http://127.0.0.1:1/v1", "--api-key", "test-key"], + ["scripts/batch_verify.py", "unused.jsonl", + "--provider-file", "unused-provider.json"], + ) + for command in commands: + with self.subTest(script=command[0]): + result = subprocess.run( + [sys.executable, *command, "--extra-body", "{"], + cwd=ROOT, env=env, capture_output=True, text=True, timeout=15, + ) + self.assertEqual(result.returncode, 2, result.stderr) + self.assertIn("Invalid JSON for --extra-body", result.stderr)