Repository navigation
Commit 6361b3a
fix(issues): Return 400 for InvalidSearchQuery during bulk delete and update (#128414)
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.
<!--
Sentry employees and contractors can delete or ignore the following.
-->
### 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.
<!-- SEER_FIXES_SENTRY_ISSUE -->
Fixes
[SENTRY-5Z50](https://sentry.sentry.io/issues/7805127888/?seerDrawer=true)
<!-- /SEER_FIXES_SENTRY_ISSUE -->
<sub>`@sentry <feedback>`: Autofix iterates on these changes</sub>
<sub>`@sentry stop iterating`: Autofix stops iterating on this run</sub>
---------
Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
Co-authored-by: cvxluo <27893746+cvxluo@users.noreply.github.com>
Co-authored-by: Charlie Luo <cvxluo@gmail.com>
Co-authored-by: Francis Genet <francis.genet@gmail.com>1 parent 3a31e48 commit 6361b3a
2 files changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| 191 | + | |
| 192 | + | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
332 | 333 | | |
333 | 334 | | |
334 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
335 | 340 | | |
336 | 341 | | |
337 | 342 | | |
| |||
0 commit comments