-
Notifications
You must be signed in to change notification settings - Fork 192
Attempt to retry 403 errors when they are actually secondary throttling limit #3358
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
Merged
Conversation
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
seanstory
previously approved these changes
Apr 18, 2025
Member
seanstory
left a comment
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.
lgtm
da503fa
seanstory
previously approved these changes
Apr 22, 2025
b9b68f1
seanstory
approved these changes
Apr 22, 2025
💔 Failed to create backport PR(s)
To backport manually run: |
artem-shelkovnikov
added a commit
that referenced
this pull request
Apr 22, 2025
…ng limit (#3358) Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 4b940dd) # Conflicts: # connectors/sources/github.py
artem-shelkovnikov
added a commit
that referenced
this pull request
Apr 22, 2025
…ng limit (#3358) Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 4b940dd) # Conflicts: # connectors/sources/github.py
artem-shelkovnikov
added a commit
that referenced
this pull request
Apr 22, 2025
…ng limit (#3358) Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 4b940dd) # Conflicts: # connectors/sources/github.py
artem-shelkovnikov
added a commit
that referenced
this pull request
Apr 22, 2025
…ng limit (#3358) Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 4b940dd) # Conflicts: # connectors/sources/github.py
Member
Author
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
artem-shelkovnikov
added a commit
that referenced
this pull request
Apr 22, 2025
…rottling limit (#3358) (#3380) Co-authored-by: Elastic Machine <[email protected]>
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.
Closes #2636
Closes https://github.com/elastic/search-team/issues/8624
This PR attempts to fix a problem with 403 returned from GitHub being interpreted as
UNAUTHORIZEDwhen in some cases it can mean that the secondary rate limit quota has been exceeded, see https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#exceeding-the-rate-limit and changesets/action#192We use
gidgethubpackage that allows to interact with Github with a chosen HTTP client. We useaiohttpso we pass the aiohttp client intogitgethublibrary:Before this PR
aiohttp.ClientSessionwas created withraise_for_status=True. This led to the problem thatgidgethubwould not be able to handle exceptions - their status handling is build on reading the requests/responses coming from Github, ifraise_for_status=Trueis set thenaiohttpwould just bubble up.Because of this, we've never actually received exceptions from
gidgethublibrary at all. In this PR I've changedraise_for_statustoFalseand that allowedgidgethubhandle and wrap status errors. Therefore I had to change the code around to catchgidgethub.HTTPExceptioninstead ofaiohttp.ClientResponseError.gidgethub.RateLimitExceededis a subclass ofgidgethub.HTTPExceptionso I had to move itsexceptstatements up.I've checked the code for throwing
gidgethub.RateLimitExceededand it handles 403s:Why we cannot handle it on our side:
aiohttpwithraise_for_status=Truewill raise an instanceaiohttp.ClientResponseError. This will cause the body of response to be lost -aiohttp.ClientResponseErrordoes not store it and just returns a message that represents the status. See this SO question:We could work around it, but to do so we need to make an HTTP call ourselves, which we cannot do -
gidgethubdoes it.So TLDR: I've swapped our exception handling fro handling
aiohttpexceptions to handlinggidgethubexceptions to be more precise and allow properly catching 403 that is a secondary rate-limit.Checklists
Pre-Review Checklist
config.yml.example)v7.13.2,v7.14.0,v8.0.0)