fix: update rate limits from HTTP error responses - #877
Open
Shubham-Padkonde wants to merge 2 commits into
Open
Shubham-Padkonde wants to merge 2 commits into
Shubham-Padkonde wants to merge 2 commits into
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
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.
Change summary
Update the client's rate-limit counters from valid response headers before returning an HTTP error. Previously, a
429response leftRateLimitRemaining()andRateLimitReset()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:
Changes to Core Features
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-lintv2.14.0: configured formatting applied to changed files; fullrunreports 0 issues.go mod download,go mod tidy, andgit 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.