🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

[Bug]: A2A Client incorrectly handles HTTP error responses when using streaming mode #502

Closed

Description

@efunneko

What happened?

Summary

The client side code incorrectly handles HTTP error responses when using streaming mode. Instead of
surfacing the actual HTTP status code and error message, the SDK attempts to parse error
responses as Server-Sent Events (SSE) and reports an SSE protocol error.

For example, an authentication failure (401) gives this exception:

HTTP Error 400: Invalid SSE response or protocol error: Expected response header Content-Type to 
contain 'text/event-stream', got 'application/json'    

Environment

• Component: A2A Python SDK (0.3.7)
• Affected Module: a2a.client.base_client
• Transport: JSON-RPC over HTTP with SSE streaming

Expected Behavior

When an A2A agent returns an HTTP error response (e.g., 500, 503, 401, 404):

1 SDK detects the non-2xx HTTP status code
2 SDK reads the error response body
3 SDK raises A2AClientHTTPError with the actual status code and error message

Example:

A2AClientHTTPError: HTTP 500 - Internal Server Error: Database connection failed                 

Actual Behavior

The SDK attempts to parse all responses as SSE streams, regardless of HTTP status code:

1 SDK tries to parse response as text/event-stream
2 SDK encounters Content-Type: application/json (typical for error responses)
3 SDK raises an SSE protocol error with status 400
4 The actual HTTP status code is lost

Example:

HTTP Error 400: Invalid SSE response or protocol error: Expected response header Content-Type to 
contain 'text/event-stream', got 'application/json'                                              

Impact

• Lost Error Information: Actual HTTP status codes and error messages are completely lost
• Misleading Errors: All HTTP errors appear as "400 Bad Request"
• Can't properly deal with expired tokens for oauth
• Broken Retry Logic: Cannot distinguish between transient (503) and permanent (500) errors
• Difficult Debugging: Impossible to diagnose downstream agent failures

Affected Scenarios

This affects all HTTP error responses in streaming mode, including:

• 500 Internal Server Error
• 503 Service Unavailable
• 401 Unauthorized
• 404 Not Found
• Any other 4xx or 5xx status code

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added theissue type on Oct 12, 2025
  2. self-assigned this
    on Oct 21, 2025
  3. Varun9002 commented on Dec 1, 2025

    @Varun9002

    Have a similar issue in case of streaming call, when passing a task id that is not available on the agent the agent server throws a ServerError but no error is propogated to the client the client behaves like the sse stream was normally closed.

    Is this somehow related to this issue?

  4. lkawka commented on Dec 3, 2025

    @lkawka
    Member

    Hi Varun9002, yes, I believe that both issues are related. We seem to incorrectly handle errors on the client. #576 should fix this.

  5. added a commit that references this issue on Dec 3, 2025
    7ea7475
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions