Skip to content

Conversation

@lkawka
Copy link
Member

@lkawka lkawka commented Dec 3, 2025

Description

Refine error management for the streaming operation. Previously, errors were converted into stream parts, resulting in the loss of status info. The updated logic now first verifies if the request was successful; if it failed, a client error is returned, preserving the relevant status information.

  • Follow the CONTRIBUTING Guide.
  • Make your Pull Request title in the https://www.conventionalcommits.org/ specification.
    • Important Prefixes for release-please:
      • fix: which represents bug fixes, and correlates to a SemVer patch.
      • feat: represents a new feature, and correlates to a SemVer minor.
      • feat!:, or fix!:, refactor!:, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.
  • Ensure the tests and linter pass (Run bash scripts/format.sh from the repository root to format)
  • Appropriate docs were updated (if necessary)

Fixes #502 🦕

@lkawka lkawka requested a review from a team as a code owner December 3, 2025 10:42
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lkawka, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the error handling mechanism for streaming operations within the client's JSONRPC and REST transports. The primary goal is to prevent the loss of critical HTTP status information when a streaming request encounters an error. By introducing explicit status checks and proper error propagation, the client can now accurately identify and respond to server-side issues during streaming, leading to more robust and reliable communication.

Highlights

  • Enhanced Error Handling for Streaming: Improved the error management for streaming operations in both JSONRPC and REST transports. Previously, HTTP errors during streaming could lead to a loss of status information, as they were implicitly converted into stream parts.
  • Direct HTTP Status Error Propagation: The updated logic now explicitly checks for unsuccessful HTTP requests using raise_for_status() and propagates httpx.HTTPStatusError as A2AClientHTTPError, ensuring that relevant status codes (e.g., 4xx, 5xx) are preserved and returned to the client.
  • New Test Coverage: Added new unit tests for both JsonRpcTransport and RestTransport to specifically verify that server errors (e.g., 403 Forbidden) are correctly propagated when streaming messages.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@lkawka lkawka changed the title fix: Handle streaming errors fix: Improve streaming errors handling Dec 3, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly refines error management for streaming operations by adding raise_for_status() to check for HTTP errors before processing the stream. The changes in send_message_streaming for both JSON-RPC and REST transports are well-implemented and are accompanied by good tests. I've added a couple of minor suggestions to make the new tests slightly more concise. One important point: this new error handling logic appears to be missing from the resubscribe methods in both src/a2a/client/transports/jsonrpc.py and src/a2a/client/transports/rest.py. Since resubscribe is also a streaming operation, I strongly recommend applying the same fix there to ensure consistent and robust error handling across all streaming endpoints.

@lkawka lkawka merged commit 7ea7475 into a2aproject:main Dec 3, 2025
8 checks passed
@lkawka lkawka deleted the streaming-fix branch December 3, 2025 14:52
lkawka pushed a commit that referenced this pull request Dec 3, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.3.20](v0.3.19...v0.3.20)
(2025-12-03)


### Bug Fixes

* Improve streaming errors handling
([#576](#576))
([7ea7475](7ea7475))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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 incorrectly handles HTTP error responses when using streaming mode

2 participants