fix(search): Reject unsupported project inbox sorts - #122414
Open
cvxluo wants to merge 1 commit into
Open
Conversation
Inbox sorting is implemented only by organization issue search. Remove its project API documentation and generic executor registration. Project requests now return 400 instead of sending an empty aggregation name to Snuba. Fixes SENTRY-5N94 Co-authored-by: Claude <noreply@anthropic.com>
cvxluo
marked this pull request as ready for review
August 21, 2026 20:11
Comment on lines
1248
to
1250
| } | ||
|
|
||
| aggregation_defs = { |
Contributor
There was a problem hiding this comment.
Bug: Removing inbox from sort_strategies without adding API-level validation can cause a KeyError when sort_by='inbox' is passed, as the code directly accesses self.sort_strategies[sort_by].
Severity: HIGH
Suggested Fix
Add validation at the API layer, likely in build_query_params_from_request(), to ensure the sort parameter is one of the allowed values defined in the OpenAPI specification. This will reject invalid sort options like inbox before they reach the query executor, preventing the KeyError.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/sentry/search/snuba/executors.py#L1248-L1250
Potential issue: The pull request removes the `"inbox"` key from the
`PostgresSnubaQueryExecutor.sort_strategies` dictionary. However, there is no
corresponding input validation at the API layer to prevent clients from sending
`sort=inbox`. When an API request like `GET
/api/projects/{org}/{project}/issues/?sort=inbox` is made, the `sort_by` parameter
reaches the executor. The code then attempts to access `self.sort_strategies["inbox"]`,
which results in an unhandled `KeyError` because the key no longer exists. The existing
fallback logic does not handle this case, leading to a server error.
Also affects:
src/sentry/apidocs/parameters.py:408~414
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Inbox sorting is implemented only by organization issue search, so remove its project API documentation and generic executor registration.
Project requests now return 400 instead of sending an empty aggregation name to Snuba.
Fixes SENTRY-5N94