You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: A2A Client incorrectly handles HTTP error responses when using streaming mode #502
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
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.
Activity
Varun9002 commentedon Dec 1, 2025
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?
lkawka commentedon Dec 3, 2025
Hi Varun9002, yes, I believe that both issues are related. We seem to incorrectly handle errors on the client. #576 should fix this.
fix: Improve streaming errors handling (a2aproject#576)