fix(tools): add timeouts to HTTP requests in API client helpers#6301
Open
agharsallah wants to merge 1 commit into
Open
fix(tools): add timeouts to HTTP requests in API client helpers#6301agharsallah wants to merge 1 commit into
agharsallah wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The requests.get/post calls in the API Hub and Application Integration tool clients omitted timeout=, so python-requests would wait forever on a stalled endpoint, hanging the tool invocation (and the agent). This also brought the clients in line with load_web_page.py, which already sets a default request timeout. Add a module-level _REQUEST_TIMEOUT_SECONDS constant (30s, matching load_web_page.py) to each client module and pass timeout= to every request call site. Extend the existing client tests to assert the mocked request receives timeout. Signed-off-by: agharsallah <17379925+agharsallah@users.noreply.github.com>
3fb0319 to
5f829c1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
2. Or, if no issue exists, describe the change:
Problem:
Every
requests.get/requests.postcall in the API Hub and ApplicationIntegration tool clients omitted the
timeout=argument.python-requestsdefaults to no timeout, so a stalled or unresponsive endpoint hangs the tool
invocation — and therefore the agent — indefinitely. This was also an internal
inconsistency:
load_web_page.pyalready sets a default request timeout(
_DEFAULT_TIMEOUT_SECONDS = 30).Affected call sites:
src/google/adk/tools/apihub_tool/clients/apihub_client.py(4requests.get)src/google/adk/tools/application_integration_tool/clients/connections_client.py(1requests.get)src/google/adk/tools/application_integration_tool/clients/integration_client.py(1requests.post)Solution:
Add a module-level
_REQUEST_TIMEOUT_SECONDS = 30constant to each clientmodule (matching the value used in
load_web_page.py) and passtimeout=toevery request call site. Keeping a named constant per module makes the value
discoverable and easy to tune, consistent with the existing pattern.
Testing Plan
Unit Tests:
Extended the existing client tests to assert the mocked
requests.*callreceives a
timeoutargument (timeout=ANY).Manual End-to-End (E2E) Tests:
Not applicable — this is a minimal, behavior-preserving change (adds a request
timeout only). Existing unit tests cover the request call sites.
Checklist
🤖 Generated with Claude Code