-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: add explicit timeout to OpenAPI tool httpx client #4432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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. |
Summary of ChangesHello @fuki01, 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 addresses an issue where OpenAPI tool HTTP requests were failing due to an unexpected timeout. The underlying HTTP client library, Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
|
|
Response from ADK Triaging Agent Hello @fuki01, thank you for creating this PR! Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). In addition, could you please provide a testing plan and logs or screenshot after the fix is applied? This information will help reviewers to review your PR more efficiently. Thanks! |
There was a problem hiding this 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 addresses a httpx.ReadTimeout issue by setting an explicit timeout=None for the httpx.AsyncClient, restoring the previous behavior of the requests library. While this fixes the immediate problem, I have a significant concern about disabling timeouts altogether, as it can lead to service instability. I've added a high-severity comment recommending the use of a large default timeout as a safety measure instead of completely disabling it.
| async with httpx.AsyncClient( | ||
| verify=request_params.pop("verify", True) | ||
| verify=request_params.pop("verify", True), | ||
| timeout=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While setting timeout=None restores the previous behavior of requests and fixes the immediate httpx.ReadTimeout issue, it introduces a significant risk. Disabling timeouts can cause requests to hang indefinitely if the remote API is unresponsive, potentially leading to resource exhaustion and service instability.
Even though a follow-up is mentioned in the pull request description, I strongly recommend addressing this now by setting a generous default timeout (e.g., 10 minutes) instead of None. This would provide a crucial safety net. A truly indefinite timeout should be an explicit choice by the user of the tool, not the default behavior.
The migration from `requests` to `httpx.AsyncClient` in PR google#2872 did not specify a timeout parameter. Since `requests` defaults to no timeout while `httpx` defaults to 5 seconds, this causes `ReadTimeout` errors for API calls that take longer than 5 seconds. Set timeout to `None` to restore the previous behavior. Closes google#4431
415aa5a to
69d0179
Compare
Summary
requeststohttpx.AsyncClient, but did not specify a timeoutrequestsdefaults to no timeout, whilehttpxdefaults to 5 secondshttpx.ReadTimeoutfor API calls taking longer than 5 secondsThis PR sets
timeout=Noneto restore the previousrequestsbehavior as a minimal fix.Note:
None(no timeout) matches the previous behavior, but the team may want to choose a more appropriate default value in a follow-up.Closes #4431