Skip to content

fix(compat): return HTTP errors from v0.3 REST streams that fail early - #1403

Open
jaeminbird wants to merge 1 commit into
a2aproject:mainfrom
jaeminbird:fix/v03-rest-stream-bad-body
Open

jaeminbird wants to merge 1 commit into
a2aproject:mainfrom
jaeminbird:fix/v03-rest-stream-bad-body

Conversation

@jaeminbird

Copy link
Copy Markdown

Description

The v0.3 REST adapter starts the SSE response before the handler runs, so any error raised before the first event becomes an empty 200 text/event-stream: a malformed message:stream body (even {bad), or tasks/{id}:subscribe for an unknown task. message:send answers 400 for the same body, and the v1.0 routes answer 400/404.

_handle_streaming_request now fetches the first event before creating the response, as RestDispatcher._handle_streaming already does, so @rest_stream_error_handler maps these errors to the usual JSON error. Mid-stream behaviour is unchanged. Follow-up to #1401, which noted this as a separate problem.

  • New tests (malformed message:stream → 400, unknown-task subscribe → 404, events still streamed in order) fail on main and pass with the fix.

  • scripts/lint.sh and uv run pytest on Linux pass.

  • Follow the CONTRIBUTING Guide.

  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.

  • Ensure the tests and linter pass

  • Appropriate docs were updated (not needed)

The v0.3 REST adapter started the SSE response before running the
handler, so a malformed message:stream body or an unknown task on
tasks/{id}:subscribe produced an empty 200 text/event-stream. Fetch the
first event before starting the stream, as the v1.0 REST dispatcher
does, so these errors get the same JSON error response as message:send.
@jaeminbird
jaeminbird requested a review from a team as a code owner October 29, 2026 09:54
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/compat/v0_3/rest_adapter.py 77.14% 78.05% 🟢 +0.91%
Total 93.37% 93.36% 🔴 -0.01%

Generated by coverage-comment.yml

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.

1 participant