Skip to content

Conversation

@andrewhibbert
Copy link
Contributor

Adds support to backoff when a rate limit error occurs as per handle rate limit errors appropriately:

  • If the retry-after response header is present, you should not retry your request until after that many seconds has elapsed.
  • If the x-ratelimit-remaining header is 0, you should not make another request until after the time specified by the x-ratelimit-reset header. The x-ratelimit-reset header is in UTC epoch seconds.
  • [N/A]When introducing a new scaler, I agree with the scaling governance policy
  • I have verified that my change is according to the deprecations & breaking changes policy
  • Tests have been added
  • Changelog has been updated and is aligned with our changelog requirements
  • [N/A] A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #6643

Relates to kedacore/keda-docs#1557

andrewhibbert and others added 23 commits March 11, 2025 18:49
@andrewhibbert andrewhibbert requested a review from a team as a code owner October 21, 2025 19:35
@keda-automation keda-automation requested a review from a team October 21, 2025 19:35
@github-actions
Copy link

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

if retryAfterStr := header.Get("Retry-After"); retryAfterStr != "" {
retrySeconds, err := strconv.Atoi(retryAfterStr)
if err != nil {
return RateLimit{}, fmt.Errorf("failed to parse Retry-After header. Returned error: %s", err.Error())
Copy link

@semgrep-app semgrep-app bot Oct 21, 2025

Choose a reason for hiding this comment

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

Semgrep found a possible error wrong wrapped.

🥳 Fixed in commit 9e21288 🥳

resetStr := header.Get("X-RateLimit-Reset")
reset, err := strconv.ParseInt(resetStr, 10, 64)
if err != nil {
return RateLimit{}, fmt.Errorf("failed to parse X-RateLimit-Reset header. Returned error: %s", err.Error())
Copy link

@semgrep-app semgrep-app bot Oct 21, 2025

Choose a reason for hiding this comment

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

Semgrep found a possible error wrong wrapped.

🥳 Fixed in commit 9e21288 🥳

remainingStr := header.Get("X-RateLimit-Remaining")
remaining, err := strconv.Atoi(remainingStr)
if err != nil {
return RateLimit{}, fmt.Errorf("failed to parse X-RateLimit-Remaining header. Returned error: %s", err.Error())
Copy link

@semgrep-app semgrep-app bot Oct 21, 2025

Choose a reason for hiding this comment

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

Semgrep found a possible error wrong wrapped.

🍰 Fixed in commit 9e21288 🍰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement backoff when receive rate limit errors in the Github scaler

2 participants