fix(api-logs): preserve snuba policy info on throttles#116263
Merged
cvxluo merged 2 commits intoMay 27, 2026
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
…ot a rejection When snuba returns 429 from a throttle path (e.g. TOO_MANY_BYTES from BytesScannedRejectingPolicy's limit_bytes_instead_of_rejecting), the response's quota_allowance.summary.throttled_by carries throttle_threshold rather than rejection_threshold. Subscripting policy_info["rejection_threshold"] raised KeyError, which was swallowed and fell through to a bare RateLimitExceeded with no policy/storage_key — wiping the SnubaRateLimitMeta downstream and leaving api.access logs with rate_limit_type=snuba but blank snuba_policy / snuba_storage_key. Co-authored-by: Claude <noreply@anthropic.com>
44dcaf9 to
1bc1597
Compare
shayna-ch
approved these changes
May 26, 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.
I'm noticing that several api access logs are missing snuba policy info, even though they show a rate limit category of 'snuba'. I believe this is because we (me 9 months ago) originally focused on only errors returned from snuba, writing this line
rejection_threshold=policy_info["rejection_threshold"],assuming thatrejection_thresholdwould be on every snuba error. However, throttling seems to be a big source of errors as well, and doesn't have that field, leading to us accidentally not attaching the policy info on throttled errors. Fix the error by using.getinstead.I chose this fix since I wanted to make the safest possible fix for now. We can look at putting 'throttled_by' in the rate limit error later.