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

Make the Secondary Rate limit check more resiliant #16

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions github_ratelimit/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"io"
"net/http"
"strings"
)

type SecondaryRateLimitBody struct {
Expand All @@ -13,12 +14,12 @@ type SecondaryRateLimitBody struct {
}

const (
SecondaryRateLimitMessage = `You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.`
SecondaryRateLimitMessage = `You have exceeded a secondary rate limit`
SecondaryRateLimitDocumentationURL = `https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits`
)

func (s SecondaryRateLimitBody) IsSecondaryRateLimit() bool {
return s.Message == SecondaryRateLimitMessage && s.DocumentURL == SecondaryRateLimitDocumentationURL
return strings.Contains(s.Message, SecondaryRateLimitMessage) && s.DocumentURL == SecondaryRateLimitDocumentationURL
bl-robinson marked this conversation as resolved.
Show resolved Hide resolved
}

// isSecondaryRateLimit checks whether the response is a legitimate secondary rate limit.
Expand Down