Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/band/integrations/omp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions tests/integrations/test_omp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

import sys

import pytest

from band.integrations.omp import (
Expand Down Expand Up @@ -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",
[
Expand Down
Loading