From 71255e4aee7e3e5346f3ede3b7e1ef792de035ad Mon Sep 17 00:00:00 2001 From: bandzalkin Date: Wed, 21 Oct 2026 15:36:13 +0300 Subject: [PATCH] fix(omp): keep a Band tool's identity for an oversized integer payload json.loads raises a bare ValueError, not JSONDecodeError, when an integer literal exceeds the interpreter's digit limit. That payload escaped the device-write normalizer and failed the turn instead of reaching the tool as a refused call under its own name. --- src/band/integrations/omp.py | 2 +- tests/integrations/test_omp.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/band/integrations/omp.py b/src/band/integrations/omp.py index a4370d697..e65cc3bfc 100644 --- a/src/band/integrations/omp.py +++ b/src/band/integrations/omp.py @@ -291,7 +291,7 @@ def normalize_omp_mcp_device_call( return name, args try: parsed = json.loads(content) - except json.JSONDecodeError: + except ValueError: return canonical, args if not isinstance(parsed, dict): return canonical, args diff --git a/tests/integrations/test_omp.py b/tests/integrations/test_omp.py index 8667243fc..15e2c8924 100644 --- a/tests/integrations/test_omp.py +++ b/tests/integrations/test_omp.py @@ -2,6 +2,8 @@ from __future__ import annotations +import sys + import pytest from band.integrations.omp import ( @@ -159,6 +161,25 @@ def test_a_malformed_write_to_a_band_tool_keeps_its_identity(content: str) -> No ) == ("band_send_message", arguments) +def test_an_oversized_integer_payload_keeps_the_tool_identity() -> None: + """``json.loads`` refuses an integer past the interpreter's digit limit + with a bare ``ValueError``; that payload is malformed like any other.""" + arguments = { + "path": "xd://mcp__band_send_message", + "content": '{"count":' + "9" * 5000 + "}", + "append": False, + } + limit = sys.get_int_max_str_digits() + sys.set_int_max_str_digits(4300) + try: + projected = normalize_omp_mcp_device_call( + "write", arguments, frozenset({"band_send_message"}), kind="execute" + ) + finally: + sys.set_int_max_str_digits(limit) + assert projected == ("band_send_message", arguments) + + @pytest.mark.parametrize( "arguments", [