Skip to content

fix: Improve error handling for Timeout exceptions on REST and JSON-RPC clients#690

Merged
guglielmo-san merged 1 commit intoa2aproject:mainfrom
guglielmo-san:guglielmoc/fix_timeout_erorrs
Feb 13, 2026
Merged

fix: Improve error handling for Timeout exceptions on REST and JSON-RPC clients#690
guglielmo-san merged 1 commit intoa2aproject:mainfrom
guglielmo-san:guglielmoc/fix_timeout_erorrs

Conversation

@guglielmo-san
Copy link
Member

This PR standardizes timeout error handling across the JSON-RPC and REST clients.

Previously, only the JSON-RPC client (in non-streaming mode) handled ReadTimeout exceptions, while streaming calls and the REST client catch them incorrectly.
Updating both JsonRpcTransport and RestTransport to catch the base httpx.TimeoutException, all timeout types (Read, Connect, Write, Pool) are consistently caught and wrapped in A2AClientTimeoutError.

This ensures consistent behavior for API consumers regardless of the transport (REST vs JSON-RPC) or mode (Streaming vs Non-Streaming) being used, preventing generic errors when network timeouts occur.

…in JSON-RPC and REST transports, with added streaming timeout tests.
@guglielmo-san guglielmo-san requested a review from a team as a code owner February 13, 2026 13:10
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @guglielmo-san, 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 significantly improves the robustness and consistency of error handling for network timeouts within the client libraries. By centralizing the catching of httpx.TimeoutException and re-raising it as a custom A2AClientTimeoutError, API consumers will experience predictable and unified error behavior across all client types and communication modes, preventing generic error propagation during network issues.

Highlights

  • Standardized Timeout Handling: Standardized timeout error handling across JSON-RPC and REST clients by catching the base httpx.TimeoutException instead of more specific or absent timeout catches.
  • Consistent Error Propagation: Ensured all types of httpx.TimeoutException (Read, Connect, Write, Pool) are consistently caught and re-raised as A2AClientTimeoutError for unified error reporting.
  • Streaming Call Support: Extended timeout handling to streaming calls in both JSON-RPC and REST clients, which previously lacked proper httpx.TimeoutException catching.
  • Improved JSON-RPC Non-Streaming: Updated the non-streaming JSON-RPC client to catch the broader httpx.TimeoutException instead of the more specific httpx.ReadTimeout.
  • New Unit Tests: Added new unit tests to verify correct timeout exception handling for streaming methods in both JsonRpcTransport and RestTransport.
Changelog
  • src/a2a/client/transports/jsonrpc.py
    • Updated _send_request to catch httpx.TimeoutException instead of httpx.ReadTimeout.
    • Added httpx.TimeoutException handling to send_message_streaming and resubscribe methods.
  • src/a2a/client/transports/rest.py
    • Imported A2AClientTimeoutError.
    • Implemented httpx.TimeoutException handling in send_message_streaming, _send_request, and resubscribe methods.
  • tests/client/transports/test_jsonrpc_client.py
    • Added a new test case test_send_message_streaming_timeout to validate timeout handling for streaming JSON-RPC calls.
  • tests/client/transports/test_rest_client.py
    • Imported A2AClientTimeoutError.
    • Introduced test_send_message_streaming_timeout to verify timeout handling for streaming REST calls.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
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.

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 effectively standardizes timeout error handling by catching the base httpx.TimeoutException across both JSON-RPC and REST clients. This is a good improvement that ensures consistent behavior for all types of timeouts (Read, Connect, Write, Pool). The changes are well-implemented and include corresponding tests to verify the new behavior. I have one minor suggestion to reduce code duplication for the error message string, but overall this is a solid contribution that improves the robustness of the clients.

@guglielmo-san guglielmo-san merged commit 2acd838 into a2aproject:main Feb 13, 2026
8 checks passed
@guglielmo-san guglielmo-san deleted the guglielmoc/fix_timeout_erorrs branch February 13, 2026 16:33
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.

2 participants