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", [