Skip to content

fix: update rate limits from HTTP error responses - #877

Open
Shubham-Padkonde wants to merge 2 commits into
fastly:mainfrom
Shubham-Padkonde:fix/rate-limit-error-responses
Open

Shubham-Padkonde wants to merge 2 commits into
fastly:mainfrom
Shubham-Padkonde:fix/rate-limit-error-responses

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Sep 27, 2026 •

Copy link
Copy Markdown

Change summary

Update the client's rate-limit counters from valid response headers before returning an HTTP error. Previously, a 429 response left RateLimitRemaining() and RateLimitReset() at their previous values, making client-level backoff decisions use stale information.

The original response and error are still returned. Missing or malformed headers retain the prior values, canceled requests with no response are safe, and GET/HEAD behavior is unchanged.

Fixes #857.

All Submissions:

  • Have you followed the guidelines in our Contributing document? Validation details and platform limits are below; the changelog links to this PR.
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

Validation on Windows, Go 1.27.1:

  • go test ./fastly -run=TestClient_RequestRateLimit -count=1: passed. Four cases fail before the fix. The new cases use a local HTTP server plus a canceled context, without Fastly credentials.
  • go test ./... -timeout=30s -parallel=20 -count=1: passed using the existing recorded fixtures.
  • golangci-lint v2.14.0: configured formatting applied to changed files; full run reports 0 issues.
  • go mod download, go mod tidy, and git diff --check: passed; module files unchanged.

These are the applicable Makefile checks run individually on Windows. Semgrep is not installed, and I did not run race detection or live Fastly API tests.

User Impact

Callers can read updated rate-limit state through the existing client accessors after rejected write requests.

Release considerations

No public API changes or new dependencies. Prepared and tested with Codex assistance.

@Shubham-Padkonde
Shubham-Padkonde requested a review from a team as a code owner September 27, 2026 07:03
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.

RateLimitRemaining isn't updated on error, including 429 rate limiting errors

1 participant