Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/a2a/compat/v0_3/jsonrpc_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
InternalError as CoreInternalError,
)
from a2a.server.jsonrpc_models import (
InvalidRequestError as CoreInvalidRequestError,
InvalidParamsError as CoreInvalidParamsError,
)
from a2a.server.jsonrpc_models import (
JSONRPCError as CoreJSONRPCError,
Expand Down Expand Up @@ -128,7 +128,7 @@ async def handle_request(

return self._generate_error_response(
request_id,
CoreInvalidRequestError(data=str(e)),
CoreInvalidParamsError(data=str(e)),
)

call_context = self._context_builder.build(request)
Expand Down
19 changes: 19 additions & 0 deletions tests/compat/v0_3/test_jsonrpc_app_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,25 @@ def test_get_task_not_found_v03_compat(
assert data['error']['message'] == 'Task not found'


def test_invalid_params_v03_compat(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a comment about why the request in this test has invalid params (no message parts)

client: TestClient, mock_handler: AsyncMock
) -> None:
request_payload = {
'jsonrpc': '2.0',
'id': '7',
'method': 'message/send',
'params': {'message': {'messageId': 'req', 'role': 'user'}},
}

response = client.post('/', json=request_payload)
assert response.status_code == 200
data = response.json()

assert data['id'] == '7'
assert data['error']['code'] == -32602
mock_handler.on_message_send.assert_not_called()


@pytest.mark.parametrize(
('error', 'expected_code'),
[
Expand Down
Loading