Commit 63d397e
fix(api): use numeric project ID to avoid "not actively selected" error (#312)
## Summary
`sentry issue list sentry/sentry` failed with "Project(s) sentry do not
exist or are not actively selected" because `listIssuesPaginated` passed
the project as `project:sentry` in the search query string. The Sentry
Issues API only searches within "actively selected" projects for that
syntax.
When we have the numeric project ID, we now use the `project` query
param (`Array<number>`) instead, which selects the project directly and
bypasses the "actively selected" requirement.
## Changes
Thread numeric `projectId` through `ResolvedTarget` → API calls:
- **`project_cache` schema**: add `project_id` column (schema v7) so
cached lookups also return the ID
- **`ResolvedTarget`**: add `projectId?: number`, populated from all
resolution paths (explicit targets via `getProject`, DSN detection,
cache hits, directory inference)
- **`listIssuesPaginated`**: when `projectId` is provided, use `project:
[id]` query param instead of `project:<slug>` search syntax; fall back
to slug when ID is unavailable
- **`listIssuesAllPages` / `fetchIssuesForTarget`**: pass `projectId`
through
For explicit targets (`sentry issue list org/project`), the `getProject`
call also serves as early validation — typos now fail with a clear 404
instead of a confusing "not actively selected" error from the issues
endpoint.
## Test plan
- New unit tests for `projectId` in `listIssuesPaginated` (3 tests)
- All existing tests pass (113 tests across api-client, resolve-target,
schema)
- Manual: `sentry issue list sentry/sentry -n 5` now returns issues (was
failing)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Burak Yigit Kaya <byk@sentry.io>1 parent bc81573 commit 63d397e
File tree
10 files changed
+496
-98
lines changed- src
- commands/issue
- lib
- db
- types
- test
- commands/issue
- lib
10 files changed
+496
-98
lines changedLarge diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
282 | 285 | | |
283 | 286 | | |
284 | 287 | | |
285 | | - | |
| 288 | + | |
286 | 289 | | |
287 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
288 | 312 | | |
289 | | - | |
290 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
291 | 316 | | |
292 | 317 | | |
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
| 321 | + | |
296 | 322 | | |
297 | 323 | | |
298 | 324 | | |
299 | 325 | | |
300 | 326 | | |
| 327 | + | |
301 | 328 | | |
302 | 329 | | |
303 | 330 | | |
304 | 331 | | |
305 | 332 | | |
306 | 333 | | |
307 | 334 | | |
| 335 | + | |
308 | 336 | | |
309 | 337 | | |
310 | 338 | | |
| |||
341 | 369 | | |
342 | 370 | | |
343 | 371 | | |
| 372 | + | |
344 | 373 | | |
345 | 374 | | |
346 | 375 | | |
| |||
386 | 415 | | |
387 | 416 | | |
388 | 417 | | |
389 | | - | |
| 418 | + | |
390 | 419 | | |
391 | 420 | | |
392 | 421 | | |
| |||
928 | 957 | | |
929 | 958 | | |
930 | 959 | | |
931 | | - | |
| 960 | + | |
932 | 961 | | |
933 | | - | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
934 | 965 | | |
935 | 966 | | |
936 | 967 | | |
937 | | - | |
| 968 | + | |
| 969 | + | |
938 | 970 | | |
939 | 971 | | |
940 | 972 | | |
941 | 973 | | |
942 | 974 | | |
943 | | - | |
| 975 | + | |
944 | 976 | | |
945 | 977 | | |
946 | 978 | | |
| |||
997 | 1029 | | |
998 | 1030 | | |
999 | 1031 | | |
1000 | | - | |
| 1032 | + | |
1001 | 1033 | | |
1002 | | - | |
1003 | | - | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1004 | 1040 | | |
1005 | 1041 | | |
1006 | 1042 | | |
1007 | 1043 | | |
1008 | 1044 | | |
1009 | 1045 | | |
1010 | 1046 | | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1011 | 1050 | | |
1012 | 1051 | | |
1013 | | - | |
| 1052 | + | |
1014 | 1053 | | |
1015 | 1054 | | |
1016 | 1055 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
1053 | 1057 | | |
1054 | 1058 | | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
1058 | | - | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
1059 | 1066 | | |
1060 | 1067 | | |
1061 | 1068 | | |
| |||
1064 | 1071 | | |
1065 | 1072 | | |
1066 | 1073 | | |
| 1074 | + | |
1067 | 1075 | | |
1068 | 1076 | | |
1069 | 1077 | | |
| |||
1116 | 1124 | | |
1117 | 1125 | | |
1118 | 1126 | | |
| 1127 | + | |
| 1128 | + | |
1119 | 1129 | | |
1120 | 1130 | | |
1121 | 1131 | | |
| |||
1141 | 1151 | | |
1142 | 1152 | | |
1143 | 1153 | | |
| 1154 | + | |
1144 | 1155 | | |
1145 | 1156 | | |
1146 | 1157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| 83 | + | |
81 | 84 | | |
82 | 85 | | |
83 | 86 | | |
| |||
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
711 | 717 | | |
712 | 718 | | |
713 | 719 | | |
| |||
0 commit comments