fix: Improve error handling for Timeout exceptions on REST and JSON-RPC clients by guglielmo-san · Pull Request #690 · a2aproject/a2a-python · GitHub
Skip to content

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

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

guglielmo-san merged 1 commit into
a2aproject:mainfrom
guglielmo-san:guglielmoc/fix_timeout_erorrs

Conversation

@guglielmo-san

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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.

Comment thread src/a2a/client/transports/jsonrpc.py
@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
ishymko pushed a commit that referenced this pull request Feb 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.23](v0.3.22...v0.3.23)
(2026-02-13)


### Features

* add async context manager support to BaseClient
([#688](#688))
([ae9dc88](ae9dc88))
* add async context manager support to ClientTransport
([#682](#682))
([2e45c0d](2e45c0d))
* support async card modifiers
([#654](#654))
([a802500](a802500))
* support disabling OTel instrumentation via env var
([#611](#611))
([72216b9](72216b9))


### Bug Fixes

* do not crash on SSE comment line
([#636](#636))
([3dcb847](3dcb847))
* gRPC metadata header casing and invocation_metadata() call
([#676](#676))
([390b763](390b763))
* Improve error handling for Timeout exceptions on REST and JSON-RPC
clients ([#690](#690))
([2acd838](2acd838))
* map rejected task state in proto converters
([#668](#668))
([957e92b](957e92b)),
closes [#625](#625)
* **server:** fix deadlocks on agent execution failure in non-streaming
([#614](#614))
([d3c973f](d3c973f))


### Documentation

* explicitly mention supported spec version and transports in readme
([#681](#681))
([c91d4fb](c91d4fb)),
closes [#677](#677)
* Update README to include Code Wiki badge
([2698cc0](2698cc0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
ishymko added a commit that referenced this pull request Mar 17, 2026
🤖 I have created a release *beep* *boop*
---


### ⚠ BREAKING CHANGES

* **spec**: upgrade SDK to A2A 1.0 spec and use proto-based types
([#572](#572),
[#665](#665),
[#804](#804),
[#765](#765))
* **client:** introduce ServiceParameters for extensions and include it
in ClientCallContext
([#784](#784))
* **client:** rename "callback" -> "push_notification_config"
([#749](#749))
* **client:** transport agnostic interceptors
([#796](#796))
([a910cbc](a910cbc))
* add `protocol_version` column to Task and PushNotificationConfig
models and create a migration
([#789](#789))
([2e2d431](2e2d431))
* **server:** implement `Resource Scoping` for tasks and push
notifications
([#709](#709))
([f0d4669](f0d4669))

### Features

* add GetExtendedAgentCardRequest as input parameter to
GetExtendedAgentCard method
([#767](#767))
([13a092f](13a092f))
* add validation for the JSON-RPC version
([#808](#808))
([6eb7e41](6eb7e41))
* **client:** expose close() and async context manager support on
abstract Client
([#719](#719))
([e25ba7b](e25ba7b))
* **compat:** AgentCard backward compatibility helpers and tests
([#760](#760))
([81f3494](81f3494))
* **compat:** GRPC client compatible with 0.3 server
([#779](#779))
([0ebca93](0ebca93))
* **compat:** GRPC server compatible with 0.3 client
([#772](#772))
([80d827a](80d827a))
* **compat:** legacy v0.3 protocol models, conversion logic and
utilities ([#754](#754))
([26835ad](26835ad))
* **compat:** REST and JSONRPC clients compatible with 0.3 servers
([#798](#798))
([08794f7](08794f7))
* **compat:** REST and JSONRPC servers compatible with 0.3 clients
([#795](#795))
([9856054](9856054))
* **compat:** set a2a-version header to 1.0.0
([#764](#764))
([4cb68aa](4cb68aa))
* **compat:** unify v0.3 REST url prefix and expand cross-version tests
([#820](#820))
([0925f0a](0925f0a))
* database forward compatibility: make `owner` field optional
([#812](#812))
([cc29d1f](cc29d1f))
* handle tenant in Client
([#758](#758))
([5b354e4](5b354e4))
* implement missing push notifications related methods
([#711](#711))
([041f0f5](041f0f5))
* implement rich gRPC error details per A2A v1.0 spec
([#790](#790))
([245eca3](245eca3))
* **rest:** add tenant support to rest
([#773](#773))
([4771b5a](4771b5a))
* send task as a first subscribe event
([#716](#716))
([e71ac62](e71ac62))
* **server, grpc:** Implement tenant context propagation for gRPC
requests. ([#781](#781))
([164f919](164f919))
* **server, json-rpc:** Implement tenant context propagation for
JSON-RPC requests.
([#778](#778))
([72a330d](72a330d))
* **server:** add v0.3 legacy compatibility for database models
([#783](#783))
([08c491e](08c491e))
* **spec:** add `tasks/list` method with filtering and pagination to the
specification
([#511](#511))
([d5818e5](d5818e5))
* use StreamResponse as push notifications payload
([#724](#724))
([a149a09](a149a09))
* **rest:** update REST error handling to use `google.rpc.Status`
([#838](#838))
([ea7d3ad](ea7d3ad))


### Bug Fixes

* add history length and page size validations
([#726](#726))
([e67934b](e67934b))
* allign error codes with the latest spec
([#826](#826))
([709b1ff](709b1ff))
* **client:** align send_message signature with BaseClient
([#740](#740))
([57cb529](57cb529))
* get_agent_card trailing slash when agent_card_path=""
([#799](#799))
([#800](#800))
([a55c97e](a55c97e))
* handle parsing error in REST
([#806](#806))
([bbd09f2](bbd09f2))
* Improve error handling for Timeout exceptions on REST and JSON-RPC
clients ([#690](#690))
([2acd838](2acd838))
* Improve streaming errors handling
([#576](#576))
([7ea7475](7ea7475))
* properly handle unset and zero history length
([#717](#717))
([72a1007](72a1007))
* return entire history when history_length=0
([#537](#537))
([acdc0de](acdc0de))
* return mandatory fields from list_tasks
([#710](#710))
([6132053](6132053))
* taskslist error on invalid page token and response serialization
([#814](#814))
([a102d31](a102d31))
* use correct REST path for Get Extended Agent Card operation
([#769](#769))
([ced3f99](ced3f99))
* Use POST method for REST endpoint /tasks/{id}:subscribe
([#843](#843))
([a0827d0](a0827d0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Ivan Shymko <ishymko@google.com>
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