Skip to content

fix: keep the longer rate limit when a later response sends a shorter one - #5946

Merged
jamescrosswell merged 4 commits into
mainfrom
fix/keep-longer-rate-limit
Nov 16, 2026
Merged

jamescrosswell merged 4 commits into
mainfrom
fix/keep-longer-rate-limit

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

HttpTransportBase.ExtractRateLimits wrote each X-Sentry-Rate-Limits reset straight into a dictionary. A later response with a shorter limit for a category that was already limited replaced the longer one, and the SDK sent that category again before the quota expired. The rate limiting spec says to keep the longer one.

A type now enforces the rule, not the call site, the same way getsentry/sentry-rust#1410 fixes it. The resets live in a new internal RateLimitResets class whose ConcurrentDictionary is private. Its only write operation, Extend, stores the later of the current and new reset times, so no update path can shorten an active limit. The OrderBy(rl => rl.RetryAfter) in ExtractRateLimits, which only protected limits within one header, is removed. No public API changes.

RetryAfterHandler (429 without X-Sentry-Rate-Limits) is unchanged: it short-circuits every request while its limit is active, so a later response cannot shorten it.

This takes over the approach from the closed duplicate #5947. Same bug as getsentry/sentry-rust#1409, reported by @itsrayeedscodespace.

Closes #5945

via Ricardo Oliveira.

--

View Session [Sentry]

… one

Closes #5945

Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io>
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
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 9 of 10 mutants on the changed lines

Location Mutation Replaced with Status
src/Sentry/Internal/Http/RateLimitResets.cs:11 Equality mutation current >= resetAt Survived

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.47%. Comparing base (0230c48) to head (a6ad818).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5946      +/-   ##
==========================================
+ Coverage   77.44%   77.47%   +0.02%     
==========================================
  Files         546      547       +1     
  Lines       20053    20054       +1     
  Branches     3962     3963       +1     
==========================================
+ Hits        15531    15536       +5     
+ Misses       3658     3655       -3     
+ Partials      864      863       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sentry-junior Bot and others added 2 commits November 16, 2026 14:02
Follows the approach of #5947 and getsentry/sentry-rust#1410.

Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io>
Co-Authored-By: Ricardo Oliveira <ricardo.oliveira@sentry.io>
@sentry-junior
sentry-junior Bot marked this pull request as ready for review November 16, 2026 15:04
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shorter rate limit from a later response replaces longer one

2 participants