Skip to content
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

Fix secondary rate limits URL #3001

Merged
merged 2 commits into from Nov 27, 2023

Conversation

Letiste
Copy link
Contributor

@Letiste Letiste commented Nov 23, 2023

GitHub updated its documentation for rate limits and is now sending the following message when a secondary rate limit is triggered:

{
  "message": "You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID XXXX.",
  "documentation_url": "https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits"
}

This PR updates the check on the documentation_url to detect a secondary rate limit

@@ -1259,7 +1259,8 @@ func CheckResponse(r *http.Response) error {
}
case r.StatusCode == http.StatusForbidden &&
(strings.HasSuffix(errorResponse.DocumentationURL, "#abuse-rate-limits") ||
strings.HasSuffix(errorResponse.DocumentationURL, "#secondary-rate-limits")):
Copy link
Contributor Author

@Letiste Letiste Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be good to also check for secondary rate limit in the error message to be more resilient to future documentation updates?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, either or should be fine.

@Letiste Letiste marked this pull request as ready for review November 23, 2023 09:50
Copy link

codecov bot commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (942692e) 97.93% compared to head (adf7891) 97.93%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3001   +/-   ##
=======================================
  Coverage   97.93%   97.93%           
=======================================
  Files         150      150           
  Lines       12952    12952           
=======================================
  Hits        12685    12685           
  Misses        190      190           
  Partials       77       77           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Letiste !

github/github.go Outdated Show resolved Hide resolved
Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@Letiste Letiste requested a review from gmlewis November 24, 2023 14:17
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Letiste !
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Nov 24, 2023
Copy link
Contributor

@liaodaniel liaodaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis gmlewis removed the NeedsReview PR is awaiting a review before merging. label Nov 26, 2023
@gmlewis
Copy link
Collaborator

gmlewis commented Nov 26, 2023

Thank you, @liaodaniel !
Merging.

@gmlewis gmlewis merged commit 182859f into google:master Nov 27, 2023
7 checks passed
gmlewis pushed a commit to o-sama/go-github that referenced this pull request Dec 19, 2023
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.

None yet

3 participants