Skip to content

fix(jsonrpc): return JSON-RPC errors as HTTP 200 and dispatch on A2A-Version - #747

Merged
JakubWorek merged 2 commits into
mainfrom
jakubworek/jsonrpc-error-status
Sep 23, 2026
Merged

JakubWorek merged 2 commits into
mainfrom
jakubworek/jsonrpc-error-status

Conversation

@JakubWorek

Copy link
Copy Markdown
Member

Description

Two distinct bugs, both confined to the Express JSON-RPC handler.

1. JSON-RPC errors escaped as HTTP 4xx/5xx

JSONRPC-ERR-002 and VER-NEG-001.

§9.5 expresses a JSON-RPC failure in the envelope, so the HTTP status stays a transport concern. Two paths bypassed the transport handler — which already answers 200 — and leaked their own status instead:

  • a parse error from express.json() returned 400 with a correct -32700 body;
  • anything thrown before handle() (user builder, card lookup, version validation) returned 500, so a refused A2A-Version came back as a server fault carrying -32009.

Both now return 200. The 500 is kept for genuine crashes, discriminated on the mapped code rather than the error class: anything that degrades to INTERNAL_ERROR (-32603) is a server fault and keeps its 500, everything else is an outcome the envelope names. Discriminating on instanceof A2AError was the first attempt and was wrong — a bare A2AError maps to -32603, and an existing test correctly insisted that stays a 500.

2. JSON-RPC dispatched on method-name grammar instead of the version

VER-NEG-002.

The handler chose between the v1.0 and v0.3 dispatchers by inspecting the shape of body.method — PascalCase SendMessage meant 1.0, message/send meant 0.3 — and ignored A2A-Version entirely. A request omitting the header therefore means 0.3 per §3.6.1, but a SendMessage in its body still got 1.0 semantics and succeeded. §3.6.2 requires processing a request with the semantics of the version it asked for.

Routing is now the version: 0.3 (explicit, or by omitting the header) goes to the compat dispatcher, which does not recognise the 1.0 method name and refuses with -32601. This is what the REST handler and the card handler already do; JSON-RPC was the odd one out. isLegacyRequest and shouldUseLegacyFallback are deleted with their only caller.

The visible behavior change: a 1.0 client that omits A2A-Version was previously served as 1.0 and now gets -32601. That is the point of the test, and it is what §3.6.1 asks for. a2a-js's own Client sends the header on every call (multitransport-client.ts:375), so no js-to-js traffic is affected, and the e2e and compat suites confirm it.

Before:

ACTS a2a-js / jsonrpc — 111 tests in 33502ms
  MUST   57/59 passed (2 failed, 6 skipped)
  SHOULD 28/29 passed (1 failed, 4 skipped)
  MAY    13/13 passed
  => NOT CONFORMANT
    JSONRPC-ERR-002: status should equal 200, got 400
    VER-NEG-001: status should equal 200, got 500
    VER-NEG-002: body.error.code is missing, so it cannot be one of [-32009, -32601]

...

========================================================
ACROSS 3 BINDING(S)
========================================================
  jsonrpc   98/111 passed   must 57/59   3 failed, 0 error(s)   NOT CONFORMANT
  grpc      88/111 passed   must 47/47   0 failed, 0 error(s)   ok
  rest      92/111 passed   must 49/49   0 failed, 0 error(s)   ok
  => NOT CONFORMANT overall

After:

========================================================
ACROSS 3 BINDING(S)
========================================================
  jsonrpc  101/111 passed   must 59/59   0 failed, 0 error(s)   ok
  grpc      88/111 passed   must 47/47   0 failed, 0 error(s)   ok
  rest      92/111 passed   must 49/49   0 failed, 0 error(s)   ok
  => CONFORMANT overall

@JakubWorek
JakubWorek requested a review from a team as a code owner September 22, 2026 13:58
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage

⬇️ Download Full Report

Base PR Delta
src/server/express/json_rpc_handler.ts 78.53% 77.95% 🔴 -0.58%
Total 86.47% 86.46% 🔴 -0.01%

Generated by coverage-comment.yml

Comment thread src/server/express/json_rpc_handler.ts Resolved
@JakubWorek
JakubWorek merged commit 733259d into main Sep 23, 2026
16 checks passed
@JakubWorek
JakubWorek deleted the jakubworek/jsonrpc-error-status branch September 23, 2026 08:30
bartek-gralewicz pushed a commit that referenced this pull request Sep 24, 2026
🤖 I have created a release *beep* *boop*
---


## [1.2.1](v1.2.0...v1.2.1)
(2026-09-24)


### Bug Fixes

* issue that status or artifact events do not propagate the metatadata
to the task ([#748](#748))
([72588af](72588af))
* **jsonrpc:** return JSON-RPC errors as HTTP 200 and dispatch on
A2A-Version ([#747](#747))
([733259d](733259d))
* **rest:** ensure taskId is correctly set from path parameters when
creating push notification configs
([#740](#740))
([4a42ec1](4a42ec1))
* **server:** add optional media type validation against agent
defaultInputModes
([#745](#745))
([27659a2](27659a2))
* validate JSON-RPC response version
([#698](#698))
([e0cdc91](e0cdc91))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

2 participants