fix(core): fail closed on empty tool arguments (#4545)
This commit is contained in:
@@ -17,9 +17,11 @@ def _reject_nonstandard_json_constant(value: str) -> NoReturn:
|
||||
|
||||
def parse_function_tool_arguments(arguments: str | None) -> dict[str, Any] | None:
|
||||
"""Return parsed object arguments, or None when an approval policy cannot inspect them."""
|
||||
if arguments is None or not arguments.strip():
|
||||
return None
|
||||
try:
|
||||
parsed = json.loads(
|
||||
arguments or "{}",
|
||||
arguments,
|
||||
parse_constant=_reject_nonstandard_json_constant,
|
||||
)
|
||||
except ValueError:
|
||||
|
||||
@@ -3125,6 +3125,7 @@ class TestToolCallExecution:
|
||||
@pytest.mark.parametrize(
|
||||
"arguments",
|
||||
[
|
||||
"",
|
||||
'{"subject": "refund"',
|
||||
"null",
|
||||
"[]",
|
||||
|
||||
@@ -919,6 +919,7 @@ async def test_function_needs_approval_invalid_type_raises() -> None:
|
||||
@pytest.mark.parametrize(
|
||||
"arguments",
|
||||
[
|
||||
"",
|
||||
'{"subject": "refund"',
|
||||
"null",
|
||||
"[]",
|
||||
|
||||
Reference in New Issue
Block a user