Skip to content

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

Merged
mykytanetipa merged 4 commits into
a2aproject:mainfrom
shwetangsinha0509:fix/v03-jsonrpc-error-codes
Oct 26, 2026
Merged

mykytanetipa merged 4 commits 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

github-actions Bot commented Oct 22, 2026 •

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 93.03% 93.01% 🔴 -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
Comment thread src/a2a/compat/v0_3/jsonrpc_adapter.py
@mykytanetipa mykytanetipa self-assigned this Oct 25, 2026
Build _V03_ERROR_CODES from the members of types_v03.A2AError instead of a hand-maintained list, as suggested in review.

@mykytanetipa mykytanetipa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@mykytanetipa
mykytanetipa merged commit 8e32d53 into a2aproject:main Oct 26, 2026
17 checks passed
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)

2 participants