Repository navigation
fix: keep the longer rate limit when a later response sends a shorter one - #5947
Closed
sentry-junior[bot] wants to merge 1 commit into
Closed
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
… one `HttpTransportBase` stored rate limit resets in a dictionary that each response overwrote, so a shorter limit from a later response replaced a longer active one. The develop spec requires keeping the longer one. The resets now live in an internal `RateLimitResets` type with a private dictionary. Its only write operation, `Extend`, uses `AddOrUpdate` to keep the later of the stored and the new reset time, so no update path can shorten an active limit. The `OrderBy` on `RetryAfter`, which only covered limits within a single header, is no longer needed. Closes #5945 Co-Authored-By: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
Member
|
Duplicate of getsentry/sentry-dotnet#5946. |
Contributor
|
Mutation testing breaks the lines a PR changes on purpose, one mutation at a time, and checks that a test fails each time. A changed line no test runs fails the check, and a mutant that survives the tests only warns. Full report Sentry: tests caught 8 of 10 mutants on the changed lines
|
sentry-junior Bot
added a commit
that referenced
this pull request
Nov 16, 2026
Follows the approach of #5947 and getsentry/sentry-rust#1410. Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5947 +/- ##
=======================================
Coverage 77.44% 77.45%
=======================================
Files 546 547 +1
Lines 20053 20054 +1
Branches 3962 3963 +1
=======================================
+ Hits 15531 15533 +2
+ Misses 3658 3657 -1
Partials 864 864 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jamescrosswell
pushed a commit
that referenced
this pull request
Nov 16, 2026
… one (#5946) * fix: keep the longer rate limit when a later response sends a shorter one Closes #5945 Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io> * test: cover a longer rate limit replacing a shorter one * ref: enforce the longer rate limit in a RateLimitResets type Follows the approach of #5947 and getsentry/sentry-rust#1410. Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io> * test: cover a rate limit at its exact reset time Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Ricardo Oliveira <ricardo.oliveira@sentry.io>
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.
HttpTransportBase.ExtractRateLimitswrote eachX-Sentry-Rate-Limitsreset straight into a dictionary, so a later response with a shorter limit replaced a longer one that was still active. The rate limiting spec requires keeping the longer one.A type enforces the rule, not the call site. The resets live in a new internal
RateLimitResetsclass whose backingConcurrentDictionaryis private. Its only write operation,Extend, usesAddOrUpdateto store the later of the current and the new reset time, so no current or future update path can shorten an active limit. With that, theOrderBy(rl => rl.RetryAfter)inExtractRateLimits, which only protected limits within a single header, is removed. No public API changes.RetryAfterHandler(429 withoutX-Sentry-Rate-Limits) is unchanged. It short-circuits every request while its limit is active, so a later response cannot shorten it. Open question: a request already in flight when that limit is set could still return a 429 with a shorterRetry-Afterand overwrite it, if the transport can have two sends in flight at once.Same bug and fix pattern as getsentry/sentry-rust#1409 (reported by @itsrayeedscodespace) and getsentry/sentry-rust#1410.
Closes #5945
via @szokeasaurusrex.
--
View Session [Sentry]