Commit 0ac022e
perf(issue): skip getProject round-trip in project-search resolution (#473)
## Summary
When resolving a project-search issue argument (e.g., `sentry issue view
acme-web-4F2K`), `resolveProjectSearch()` was doing two sequential API
steps: `findProjectsBySlug()` (calls `getProject` per org) then
`getIssueByShortId()`. Since the shortid endpoint already validates both
project and issue existence, the `getProject` call is redundant.
Now tries `tryGetIssueByShortId()` directly across all orgs in parallel,
saving one HTTP round-trip (~500-800ms). Falls back to
`findProjectsBySlug()` only when all orgs 404, so error messages stay
specific.
Addresses [CLI-EV](https://sentry.sentry.io/issues/7340600304/)
(Consecutive HTTP performance issue).
## Example: `sentry issue view acme-web-4F2K`
**Before** (6 sequential HTTP calls, ~3.5s):
```
resolveProjectSearch("acme-web", "4F2K")
|
+- tryResolveFromAlias() <-- cache miss
+- resolveFromDsn() <-- no DSN match
|
+- findProjectsBySlug("acme-web")
| +- listOrganizations()
| | +- GET /users/me/regions/ ~273ms --+
| | +- GET /organizations/ ~619ms | sequential
| | |
| +- Promise.all(orgs.map(getProject)) |
| +- GET /projects/acme-corp/acme-web/ ~783ms
| |
+- getIssueByShortId("acme-corp", ...) |
| +- GET /shortids/ACME-WEB-4F2K/ ~581ms |
| |
+- tryGetLatestEvent() |
| +- GET /issues/{id}/events/latest/ ~544ms |
| |
+- getSpanTreeLines() |
+- GET /trace/{trace_id}/ ~539ms --+
total: ~3.3s HTTP
```
**After** (5 sequential HTTP calls, ~2.5s):
```
resolveProjectSearch("acme-web", "4F2K")
|
+- tryResolveFromAlias() <-- cache miss
+- resolveFromDsn() <-- no DSN match
|
+- listOrganizations()
| +- GET /users/me/regions/ ~273ms --+
| +- GET /organizations/ ~619ms |
| |
+- Promise.all(orgs.map(tryGetIssueByShortId)) <-- skips getProject
| +- GET /shortids/ACME-WEB-4F2K/ ~581ms | one fewer
| | round-trip
+- tryGetLatestEvent() |
| +- GET /issues/{id}/events/latest/ ~544ms |
| |
+- getSpanTreeLines() |
+- GET /trace/{trace_id}/ ~539ms --+
total: ~2.5s HTTP
saved: ~783ms
```
With a warm org cache (the common case after PR #446), the regions +
organizations calls are instant, bringing the total down further.
## Changes
### Performance
- `src/lib/api/issues.ts` -- add `tryGetIssueByShortId()` (returns null
on 404 instead of throwing)
- `src/lib/api-client.ts` -- barrel export
- `src/commands/issue/utils.ts` -- rewrite `resolveProjectSearch()`: fan
out shortid lookups directly across all orgs in parallel, skipping the
intermediate `getProject()` call
### Error handling
- Surface real API errors (403, 5xx) and network errors when every org
fails, instead of masking them with "not found"
- Only throw when ALL orgs returned real errors -- a 403 from an
unrelated org does not preempt the fallback when other orgs returned
clean 404s
- Retry `getIssueByShortId` when the fallback finds the project (handles
transient failures from the fast path)
- Extract `resolveProjectSearchFallback()` to stay under cognitive
complexity lint limit
## Test plan
- `bun run typecheck` passes
- `bun run lint` passes (complexity now under 15)
- `bun test --filter "issue"` -- all 137 tests pass
- Manual: `sentry issue view <project>-<suffix>` resolves without the
extra `getProject` call
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Burak Yigit Kaya <byk@sentry.io>1 parent 9ecc62f commit 0ac022e
File tree
4 files changed
+326
-24
lines changed- src
- commands/issue
- lib
- api
- test/commands/issue
4 files changed
+326
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| |||
124 | 132 | | |
125 | 133 | | |
126 | 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 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
127 | 187 | | |
128 | 188 | | |
129 | 189 | | |
130 | 190 | | |
131 | 191 | | |
132 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
133 | 195 | | |
134 | 196 | | |
135 | 197 | | |
| |||
173 | 235 | | |
174 | 236 | | |
175 | 237 | | |
176 | | - | |
177 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
178 | 243 | | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
186 | 257 | | |
187 | 258 | | |
188 | | - | |
189 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
190 | 265 | | |
191 | 266 | | |
192 | 267 | | |
| |||
198 | 273 | | |
199 | 274 | | |
200 | 275 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
208 | 289 | | |
209 | 290 | | |
210 | | - | |
211 | | - | |
212 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
213 | 294 | | |
214 | 295 | | |
215 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
254 | 279 | | |
255 | 280 | | |
256 | 281 | | |
| |||
0 commit comments