Skip to content

fix(issues): Return 400 for InvalidSearchQuery during bulk delete and update - #128414

Merged
cvxluo merged 6 commits into
masterfrom
seer/fix/issues-bulk-delete-invalid-search-query-400
Oct 21, 2026
Merged

cvxluo merged 6 commits into
masterfrom
seer/fix/issues-bulk-delete-invalid-search-query-400

Conversation

@sentry

@sentry sentry Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

When a bulk issue delete or update request contains an invalid search query—for example ?query=issue:155261377 where a numeric group id is passed to the issue: filter instead of a qualified short id—format_search_filter raises an InvalidSearchQuery while building the Snuba query.

Because this happens inside search_fn rather than parse_and_convert_issue_search_query, the exception was not translated to a ValidationError. Both schedule_tasks_to_delete_groups and update_groups_with_search_fn only caught ValidationError, allowing InvalidSearchQuery to bubble up to the top-level endpoint exception handler, which logged an error traceback and returned HTTP 500.

This change:

  • Catches InvalidSearchQuery in schedule_tasks_to_delete_groups and returns an HTTP 400 response with {"detail": "Invalid search query."}.
  • Catches InvalidSearchQuery in update_groups_with_search_fn and returns an HTTP 400 response with {"detail": "Invalid search query."} without logging an error to Sentry.
  • Uses a generic client-safe error message rather than echoing exception internals into the response.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes SENTRY-5Z50

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

@sentry
sentry Bot requested review from a team as code owners October 21, 2026 19:05
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 21, 2026
Comment thread src/sentry/api/helpers/group_index/delete.py
Comment thread src/sentry/api/helpers/group_index/update.py Fixed
except ValidationError as exc:
return Response({"detail": str(exc)}, status=400)
except InvalidSearchQuery:
# InvalidSearchQuery can be raised while building the Snuba query

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sentry get rid of this comment

@cvxluo cvxluo added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Oct 21, 2026
…n invalid search query

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Oct 21, 2026
@cvxluo cvxluo added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Oct 21, 2026
@github-actions github-actions Bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Oct 21, 2026
@cvxluo cvxluo added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Oct 21, 2026
@cvxluo
cvxluo merged commit 6361b3a into master Oct 21, 2026
98 of 99 checks passed
@cvxluo
cvxluo deleted the seer/fix/issues-bulk-delete-invalid-search-query-400 branch October 21, 2026 22:45

This branch was successfully deployed

1 active deployment
Preview — 95fd6518 Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants