Skip to content

fix(compat): return A2A error codes from the v0.3 JSON-RPC adapter - #1369

Open
shwetangsinha0509 wants to merge 1 commit into
a2aproject:mainfrom
shwetangsinha0509:fix/v03-jsonrpc-error-codes
Open

shwetangsinha0509 wants to merge 1 commit into
a2aproject:mainfrom
shwetangsinha0509:fix/v03-jsonrpc-error-codes

Conversation

@shwetangsinha0509

Copy link
Copy Markdown

Description

A2A errors raised while handling v0.3 JSON-RPC requests fell through to the generic except Exception in JSONRPC03Adapter and were returned as -32603 InternalError. v0.3 clients could not distinguish e.g. TaskNotFoundError (-32001) from a server failure.

This maps A2AErrors to their JSON-RPC codes via JSON_RPC_ERROR_CODE_MAP in both paths, matching what JsonRpcDispatcher does for v1.0:

  • non-streaming: handle_request catches A2AError before the generic handler, and _generate_error_response builds a v0.3 JSONRPCError from it
  • streaming: event_generator yields the mapped error event instead of InternalError

Errors that only exist in v1.0 (-32008 ExtensionSupportRequired, -32009 VersionNotSupported) are not part of the v0.3 spec, so they still map to -32603. This keeps the existing expectation in tests/integration/test_version_header.py.

Tests (tests/compat/v0_3/test_jsonrpc_app_compat.py): tasks/get not found, tasks/cancel with TaskNotFoundError / TaskNotCancelableError / UnsupportedOperationError, and an error raised mid-stream on message/stream. All fail on main and pass with this change. Full suite passes locally; ruff check, ruff format and ty check are clean.

Fixes #1368 🦕

A2AErrors raised while handling v0.3 JSON-RPC requests fell through to the generic handler and were returned as -32603 InternalError, so v0.3 clients could not tell e.g. TaskNotFoundError (-32001) apart from a server failure. Map them to their JSON-RPC codes in the non-streaming and streaming paths, keeping -32603 for errors that have no v0.3 equivalent.
@shwetangsinha0509
shwetangsinha0509 requested a review from a team as a code owner October 22, 2026 12:57
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/compat/v0_3/jsonrpc_adapter.py 66.67% 68.22% 🟢 +1.55%
Total 92.90% 92.87% 🔴 -0.03%

Generated by coverage-comment.yml

@shwetangsinha0509 shwetangsinha0509 changed the title fix(compat): return A2A error codes from the v0.3 JSON-RPC adapter fix(compat): return A2A error codes from the v0.3 JSON-RPC adapter Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: v0.3 JSON-RPC compat adapter returns -32603 for all A2A errors (e.g. TaskNotFound should be -32001)

1 participant