fix: Improve error handling for Timeout exceptions on REST and JSON-RPC clients#690
Conversation
…in JSON-RPC and REST transports, with added streaming timeout tests.
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
This PR standardizes timeout error handling across the JSON-RPC and REST clients.
Previously, only the JSON-RPC client (in non-streaming mode) handled
ReadTimeoutexceptions, while streaming calls and the REST client catch them incorrectly.Updating both
JsonRpcTransportandRestTransportto 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.