fix: rate limit on one data category no longer blocks all others - #5482
Merged
Conversation
When Sentry rejects an envelope with a 429 carrying X-Sentry-Rate-Limits, the RetryAfterHandler was short-circuiting *every* subsequent request for the retry-after window, regardless of which categories were actually limited. An org over its transaction quota therefore stopped sending errors too, and because a short-circuited request produces a response (not an exception), the affected envelopes were discarded rather than retried. The per-category limits in that header are already applied per envelope item by HttpTransportBase, so the handler now only applies its blanket back off to a 429 that carries no such header, matching the SDK spec and the other SDKs. Fixes #3947 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jamescrosswell
commented
Aug 13, 2026
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jamescrosswell
commented
Aug 13, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5482 +/- ##
==========================================
- Coverage 74.73% 74.72% -0.02%
==========================================
Files 513 513
Lines 18744 18744
Branches 3666 3666
==========================================
- Hits 14009 14007 -2
- Misses 3863 3864 +1
- Partials 872 873 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jamescrosswell
marked this pull request as ready for review
August 13, 2026 03:31
bruno-garcia
approved these changes
Aug 13, 2026
|
Any ideas when this will get released? |
3 tasks
Collaborator
Author
I've just requested a 6.9.0 release, so hopefully within the next 24-48 hours. |
This was referenced Aug 17, 2026
Collaborator
Author
|
@longzheng 6.9.0 is out now. |
This was referenced Aug 17, 2026
This was referenced Aug 18, 2026
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.
Fixes #3947
Summary
An org over its transaction quota also stopped sending errors, for the duration of every rate-limit window.
Two independent rate-limit mechanisms exist in the SDK:
HttpTransportBase.ExtractRateLimitsparsesX-Sentry-Rate-LimitsintoCategoryLimitResetsand drops only the matching envelope items. This is correct.RetryAfterHandlersits at the top of the handler pipeline and short-circuits every subsequent request on any 429, without looking atX-Sentry-Rate-Limitsat all.(2) runs above (1), so the correct per-category logic was bypassed entirely: a
60:transaction;profile;span:...limit gated errors, sessions, check-ins and everything else for 60s.RetryAfterHandlernow applies its blanket back off only to a 429 that carries noX-Sentry-Rate-Limitsheader — i.e. the proxy / older-Sentry global-limit case it was written for. This matches the spec (X-Sentry-Rate-Limitsfirst;Retry-Afteron 429 only "without the above headers") and sentry-python, whoseRetry-Afterbranch is a literalelifon the header being absent.Notes for review
HandleFailurejust logs and returns, andCachingTransportthen deletes the cache file. Blocked envelopes were gone for good. The emptyServer response:in the reporter's log is the tell-tale of that synthetic response.HttpTransportTestscase buildsnew HttpClient(handler)directly, which leavesRetryAfterHandlerout of the pipeline. The new transport-level test goes throughDefaultSentryHttpClientFactoryso the handler is present, as in production. It fails onmainwithExpected requestCount to be 2 ... but found 1.X-Sentry-Rate-Limitswith empty categories is handled byRateLimitCategory.IsMatchAll, andHttpTransport.SendEnvelopeAsyncskips the HTTP call whenProcessEnvelopeleaves zero items — so delegating to the transport doesn't trade the bug for extra traffic.RetryAfterHandlerTestsall use bare 429s, so they're unaffected and still assert the fallback behaviour.🤖 Generated with Claude Code