Repository navigation
fix(replays): Use handle_query_errors across replay endpoints - #125992
Conversation
Wrap the recording segment index endpoint in handle_query_errors so Snuba errors like QueryTooManySimultaneous map to the shared API responses (429 Throttled) instead of surfacing as uncaught 500s. Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
Wrap Snuba queries in every replay endpoint with the shared handle_query_errors handler and remove the replay-specific handled_snuba_exceptions decorator. Snuba concurrency limits now return 429 everywhere instead of 400 or an uncaught 500, and memory/execution limits return the shared 504 timeout response. Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
There was a problem hiding this comment.
About the CodeQL "Information exposure through an exception" alert on organization_replay_count.py: this PR didn't introduce that code. return Response({"detail": str(e)}, status=400) is already on master (line 148). It only moved because it's now indented inside with handle_query_errors():. It returns the message from InvalidSearchQuery/ValueError, which reports invalid search input back to the caller, not a stack trace. Changing that response is out of scope here, so I'm leaving the code as is. A maintainer can dismiss the alert, or it can be handled in a separate PR.
handle_query_errors across replay endpoints
The replay-count endpoint returned str(e) for any ValueError raised while building the query, so internal or library error text could reach the client. Raise ParseError with fixed messages for user input validation in replay_counts, and let unexpected ValueErrors surface as a generic 500. Invalid search syntax still goes through handle_query_errors. Co-Authored-By: George Gritsouk <george.gritsouk@sentry.io>
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b348f74. Configure here.
When the replays ClickHouse cluster hits its concurrent query limit (
TOO_MANY_SIMULTANEOUS_QUERIES), replay endpoints return inconsistent statuses. Some let the error escape as a 500. The replay index and selector endpoints return a 400 through their ownhandled_snuba_exceptionsdecorator, which tells clients not to retry.The main motivation to fix this is to improve consistency but also to improve alerting. We get Datadog alerts on elevated 500s but I don't want to be alerted due to Snuba timeouts!
This PR wraps the Snuba query calls in every replay endpoint with the shared
handle_query_errorshandler, which most Snuba-backed endpoints already use, and deletes the replay-specific handler.Response Code Changes
QueryTooManySimultaneousThrottled)QueryMemoryLimitExceeded,QueryExecutionTimeMaximumQueryConnectionFailedException Details
The replay count endpoint no longer returns
str(e)for anyValueError. Invalid input gets aParseErrorwith a fixed message, and unexpected errors become a generic 500 so we don't leak any internal detail to Sentry users at runtime.via George Gritsouk.
--
View Junior Session [Sentry]