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
10 changes: 6 additions & 4 deletions src/a2a/compat/v0_3/jsonrpc_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,13 @@ async def _process_non_streaming_request(
else:
raise ValueError(f'Unsupported method {method}')

return JSONResponse(
content=result.model_dump(
mode='json', by_alias=True, exclude_none=True
)
content = result.model_dump(
mode='json', by_alias=True, exclude_none=True
)
# exclude_none also drops the null result of a successful delete, but
# JSON-RPC 2.0 requires the result member in every success response.
content.setdefault('result', None)
return JSONResponse(content=content)

@validate_version(constants.PROTOCOL_VERSION_0_3)
async def _process_streaming_request(
Expand Down
22 changes: 21 additions & 1 deletion tests/compat/v0_3/test_jsonrpc_app_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from a2a.compat.v0_3 import jsonrpc_adapter
from a2a.compat.v0_3 import jsonrpc_adapter, types as types_v03
from a2a.compat.v0_3.jsonrpc_adapter import JSONRPC03Adapter
from a2a.server.context import ServerCallContext
from a2a.server.request_handlers.request_handler import RequestHandler
Expand Down Expand Up @@ -162,6 +162,26 @@ def test_get_task_v03_compat(
assert data['result']['status']['state'] == 'completed'


def test_delete_push_notification_config_v03_compat_returns_null_result(
client: TestClient, mock_handler: AsyncMock
) -> None:
"""A successful delete carries `"result": null`, as JSON-RPC 2.0 requires."""
mock_handler.on_delete_task_push_notification_config.return_value = None
request_payload = {
'jsonrpc': '2.0',
'id': '5',
'method': 'tasks/pushNotificationConfig/delete',
'params': {'id': 'test_task_id', 'pushNotificationConfigId': 'cfg'},
}

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

assert data == {'jsonrpc': '2.0', 'id': '5', 'result': None}
types_v03.DeleteTaskPushNotificationConfigResponse.model_validate(data)


def test_get_extended_agent_card_v03_compat(
client: TestClient, mock_handler: AsyncMock, agent_card: AgentCard
) -> None:
Expand Down
Loading