fix(seer): Catch InvalidSearchQuery for non-hex trace IDs in _get_full_trace_id#119796
Open
sentry[bot] wants to merge 1 commit into
Open
fix(seer): Catch InvalidSearchQuery for non-hex trace IDs in _get_full_trace_id#119796sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
…l_trace_id Fixes SEER-5Y4 Explorer agent passes non-hex ULID trace IDs (e.g. '01KXGMFF86HYWPMRXXZCG7BXDY') to get_trace_waterfall RPC. The EAP search query parser raises InvalidSearchQuery because trace must be valid hex UUID, which propagates uncaught to the seer_rpc post() handler and results in HTTP 500. - Wrap the Spans.run_table_query call in _get_full_trace_id with try/except InvalidSearchQuery, returning None so non-hex trace IDs are treated as 'not found' instead of raising. - Add InvalidSearchQuery to the explicit except clauses in the seer_rpc post() handler, raising ParseError (HTTP 400) instead of letting it fall through to the generic 500 APIException handler.
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 SEER-5Y4
Problem
Seer's Explorer agent passes non-hex ULID-format trace IDs (e.g.
01KXGMFF86HYWPMRXXZCG7BXDY) to theget_trace_waterfallRPC. The EAP search query parser raisesInvalidSearchQuerybecausetracemust be a valid hex UUID (32-36 chars, a-f only). This exception propagates uncaught through_get_full_trace_id→get_trace_waterfall→rpc_get_trace_waterfall→ the seer_rpcpost()handler, which catches all genericExceptions and re-raises asAPIException(HTTP 500).Solution
Two defense-in-depth changes:
_get_full_trace_idinsrc/sentry/seer/agent/tools.py: Wrap theSpans.run_table_querycall withtry/except InvalidSearchQueryand returnNone, so non-hex trace IDs are treated as "not found" instead of raising.post()insrc/sentry/seer/endpoints/seer_rpc.py: AddInvalidSearchQueryto the explicitexceptclauses, raisingParseError(HTTP 400) instead of letting it fall through to the generic 500APIExceptionhandler. This protects against any other RPC method that might raiseInvalidSearchQuery.