Repository navigation
Commit 6f9d323
fix(search): rewrite numeric project: filters to project_id (#1621)
## Summary
Issue search treats `project` as a **slug**. Agents paste Sentry's
numeric project id into `--query` and get a 400 (CLI-FA). `project_id`
is the numeric field.
`sanitizeQuery` now rewrites `project:<digits>` and all-numeric
`project:[id,id]` to `project_id`, with a warning, same as the existing
OR → in-list repair. Slugs (`project:frontend`), already-correct
`project_id:…`, namespaced keys (`bolt.project_id`), quoted strings, and
mixed in-lists are left alone.
### Before / after
Command from CLI-FA:
```bash
sentry issue list --json -q "project:4511730126487632 environment:vercel-production"
```
**Before** — 400, `ApiError`, grouped in CLI-FA. The API rejects a
numeric value on the slug field:
```text
Error: Failed to fetch issues from 1 project(s): Failed to list issues: 400 Bad Request
Endpoint: /api/0/organizations/…/issues/
Invalid query: …
Suggestions:
• Check your --query syntax (Sentry search reference: …)
• Try a shorter time range: --period 14d or --period 24h
• Verify you have access to the target project: sentry project list <org>/
```
**After** — rewrite in `sanitizeQuery`, warn, run the query, exit 0:
```text
⚠ `project` is the slug; numeric ids use project_id. Rewrote numeric project: filters. Running query: "project_id:4511730126487632 environment:vercel-production"
```
Stdout is the issue list JSON. Same rewrite for
`project:[4505521413357568,6442225]` → `project_id:[…]`.
## Test plan
- [ ] `sanitizeQuery("project:4511730126487632
environment:vercel-production")` → `project_id:4511730126487632
environment:vercel-production`
- [ ] `project:[4505521413357568,6442225]` rewrites;
`project:[frontend,6442225]` does not
- [ ] `project:frontend`, `project_id:123`, `bolt.project_id:70054175`,
`message:"project:123"` unchanged
- [ ] From `packages/cli`: `pnpm exec vitest run
test/lib/search-query.test.ts test/lib/search-query.property.test.ts`
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 596a6d5 commit 6f9d323
3 files changed
Lines changed: 252 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
346 | 350 | | |
347 | 351 | | |
348 | 352 | | |
| 353 | + | |
| 354 | + | |
349 | 355 | | |
350 | 356 | | |
351 | | - | |
352 | 357 | | |
353 | | - | |
354 | | - | |
| 358 | + | |
| 359 | + | |
355 | 360 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
| |||
382 | 384 | | |
383 | 385 | | |
384 | 386 | | |
385 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
386 | 390 | | |
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
390 | | - | |
391 | | - | |
392 | | - | |
| 394 | + | |
| 395 | + | |
393 | 396 | | |
| 397 | + | |
394 | 398 | | |
395 | 399 | | |
396 | 400 | | |
397 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
398 | 433 | | |
399 | 434 | | |
400 | 435 | | |
401 | 436 | | |
402 | 437 | | |
403 | 438 | | |
404 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
405 | 444 | | |
406 | 445 | | |
407 | | - | |
408 | | - | |
409 | 446 | | |
410 | 447 | | |
411 | 448 | | |
412 | 449 | | |
413 | | - | |
414 | | - | |
415 | | - | |
| 450 | + | |
416 | 451 | | |
417 | 452 | | |
418 | 453 | | |
| |||
511 | 546 | | |
512 | 547 | | |
513 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
514 | 558 | | |
515 | 559 | | |
516 | 560 | | |
| |||
519 | 563 | | |
520 | 564 | | |
521 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
522 | 583 | | |
523 | 584 | | |
524 | 585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
101 | 164 | | |
102 | 165 | | |
103 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
0 commit comments