Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.5k
Handle exceptions when parsing 'retry-after' header in rate limit handling#4931
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Pull Request Overview
This pull request improves the robustness of rate limit handling in theasync_download_file method by adding exception handling around the parsing of theretry-after HTTP header. When GitHub returns a 429 (rate limit) status, the code now safely handles cases where theretry-after header contains non-numeric values, preventing potential crashes and gracefully falling back to a 10-second default retry interval.
Key Changes
- Added try-except block to catch
ValueErrorandTypeErrorwhen parsing theretry-afterheader value - Maintains backward-compatible behavior with a sensible 10-second default on parsing errors
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
This pull request introduces a minor improvement to the rate-limit handling logic in the
async_download_filemethod. The change ensures that the value of theretry-afterheader is safely parsed, preventing potential errors if the header is missing or not an integer.retry-afterheader by adding atry...exceptblock to catch parsing errors, defaulting to 10 seconds if necessary incustom_components/hacs/base.py.