Skip to content

fix(rest): send stream errors as google.rpc.Status - #449

Merged
muscariello merged 1 commit into
stack/09-push-any-auth-schemefrom
stack/10-rest-stream-error-status
Nov 2, 2026
Merged

muscariello merged 1 commit into
stack/09-push-any-auth-schemefrom
stack/10-rest-stream-error-status

Conversation

@muscariello

Copy link
Copy Markdown
Member

Fixes #421. Replaces #422. Stacked on #448: review only the last commit.

Cause: an error inside an HTTP+JSON stream went out as a bare JSON-RPC error object, against §11.6. The REST client parsed every event as a StreamResponse, so a typed error such as TaskNotFound reached the caller as -32603 SSE parse error.

Fix: the two REST stream handlers now send an error item as the event {"error": google.rpc.Status}, built by rest_error_envelope, the same body a non-streaming REST error already has. In the client, parse_sse_stream_rest reads that envelope back into the typed A2AError through rest_error. A StreamResponse never has a top-level error key. sse::sse_from_stream is unchanged.

Behavior change: the wire shape of an error event on REST streams changes. A client that parsed the old JSON-RPC-shaped error event will no longer match it.

Tests: one server test checks the error event has error.code: 404, status: NOT_FOUND and reason TASK_NOT_FOUND; one client test decodes such an event to TaskNotFound.

Unproven: the failure on main quoted in #422 was 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!

@muscariello
muscariello force-pushed the stack/10-rest-stream-error-status branch from 6ead462 to 3a3b324 Compare November 2, 2026 12:00
@muscariello
muscariello force-pushed the stack/10-rest-stream-error-status branch from 3a3b324 to ebfc330 Compare November 2, 2026 12:02
An error inside an HTTP+JSON stream went out as a bare JSON-RPC error
object, and the REST client failed to parse it, so the caller saw
"SSE parse error" (-32603) instead of the typed error. Section 11.6 says
HTTP+JSON errors use the {"error": google.rpc.Status} body. The REST
binding now sends that body as the stream event, built by the same code as
a non-streaming error response, and the REST client reads it back into the
typed A2AError, through the same parser it uses for error responses.

Signed-off-by: gulldan <[email protected]>
@muscariello
muscariello force-pushed the stack/10-rest-stream-error-status branch from ebfc330 to 9f26dd4 Compare November 2, 2026 14:28
@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 51b6c9a Nov 2, 2026
43 of 45 checks passed
@muscariello
muscariello deleted the stack/10-rest-stream-error-status branch November 2, 2026 17:44
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
gulldan added a commit to gulldan/a2a-rs that referenced this pull request Nov 3, 2026
An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (a2aproject#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Co-Authored-By: Claude Mythos 5.1 <[email protected]>
Signed-off-by: gulldan <[email protected]>
gulldan added a commit to gulldan/a2a-rs that referenced this pull request Nov 3, 2026
An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (a2aproject#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Co-Authored-By: Claude Mythos 5.1 <[email protected]>
Signed-off-by: gulldan <[email protected]>
muscariello pushed a commit that referenced this pull request Nov 3, 2026
An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Co-Authored-By: Claude Mythos 5.1 <[email protected]>
Signed-off-by: gulldan <[email protected]>
muscariello pushed a commit that referenced this pull request Nov 3, 2026
An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Co-Authored-By: Claude Mythos 5.1 <[email protected]>
Signed-off-by: gulldan <[email protected]>
muscariello pushed a commit that referenced this pull request Nov 4, 2026
An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Signed-off-by: gulldan <[email protected]>
muscariello pushed a commit that referenced this pull request Nov 4, 2026
An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Signed-off-by: gulldan <[email protected]>
gulldan added a commit to gulldan/a2a-rs that referenced this pull request Nov 4, 2026
* test(rest): stream error event name

Signed-off-by: gulldan <[email protected]>

* fix(rest): name an error frame in a stream "error"

An error inside an HTTP+JSON stream was sent as an unnamed SSE frame
carrying the google.rpc.Status body (a2aproject#449). a2a-python's REST client
treats a frame as an error only when its event name is "error" and reads
every other frame as a StreamResponse, so the error was dropped on the
floor and the consumer got an empty event instead. a2a-python's own REST
server names the frame; this does the same. The JSON-RPC binding is
unchanged: its error travels inside the envelope.

Signed-off-by: gulldan <[email protected]>

* fix(rest): keep sse_from_stream's signature

Naming the error frame needs a serializable error type, which changed the
signature of the public sse_from_stream. Leave it as it was, give rest_sse
its own pub(crate) sse_from_rest_stream, and test the frame name there, so
the fix is not a breaking change to a2a-server-lf.

Signed-off-by: Luca Muscariello <[email protected]>

---------

Signed-off-by: gulldan <[email protected]>
Signed-off-by: Luca Muscariello <[email protected]>
Co-authored-by: gulldan <[email protected]>
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]: HTTP+JSON stream errors are sent as a JSON-RPC error object, and the REST client cannot read them

3 participants