Skip to content

fix(client): report the HTTP status of a non-JSON-RPC error response - #439

Merged
muscariello merged 2 commits into
mainfrom
stack/01-client-jsonrpc-http-status
Nov 2, 2026
Merged

muscariello merged 2 commits into
mainfrom
stack/01-client-jsonrpc-http-status

Conversation

@muscariello

Copy link
Copy Markdown
Member

Fixes #404. Replaces #406, restacked on in-repo branches so the stack can be reviewed one commit at a time.

Cause: JsonRpcTransport never read the HTTP status. A 401, 429 or 502 from a proxy or gateway is not a JSON-RPC envelope, so callers got INTERNAL_ERROR "failed to parse JSON-RPC response", and a streaming call answered that way without a content type reached the SSE parser and returned an empty stream.

Fix: one parse_jsonrpc_response(status, body) replaces three copies of the envelope parse. A JSON-RPC body is decoded whatever the status, as before; anything else is reported as HTTP <status>: <body>, the text the REST transport already uses. A non-success status in call_streaming no longer goes to the SSE parser. The error code stays INTERNAL_ERROR.

Unproven: the new tests (a 429 on GetTask, a bare 401 on SubscribeToTask) and the before/after results in #406 were not run locally. CI is the check.

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

gulldan and others added 2 commits November 2, 2026 13:02
The JSON-RPC transport never looked at the status of a response. An
error that something in front of the agent answers itself (an
authenticating proxy's 401, a gateway's 429 or 502) carries no
JSON-RPC envelope, so the caller got "failed to parse JSON-RPC
response" and could not tell a credential or rate-limit problem from
a broken server. A streaming call answered that way without a content
type was handed to the SSE parser and came back as an empty stream.

A body that is not a JSON-RPC envelope is now reported with its
status, as the REST transport already does ("HTTP 429 Too Many
Requests: <body>"); a JSON-RPC envelope is still decoded whatever the
status, and a non-success status is never treated as a stream.

Fixes: #404

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: gulldan <[email protected]>
The streaming test matched on the result and panicked in an `Ok` arm that a
passing run never reaches, so that line stayed uncovered. Taking the error
with `.err().expect()` keeps the assertion and needs no `Debug` on the stream.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: gulldan <[email protected]>
@muscariello
muscariello force-pushed the stack/01-client-jsonrpc-http-status branch from a513c27 to 30726b0 Compare November 2, 2026 12:02
@muscariello
muscariello removed this pull request from stack #442 November 2, 2026 15:00
@muscariello
muscariello added this pull request to stack #456 November 2, 2026 15:01
@muscariello
muscariello added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit 3fb5657 Nov 2, 2026
22 checks passed
@muscariello
muscariello deleted the stack/01-client-jsonrpc-http-status branch November 2, 2026 17:44
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
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]: a2a-client: JSON-RPC transport drops the HTTP status of an error response that is not JSON-RPC

3 participants