Commit 7db4f7c
authored
## Summary
Fixes a crash in the response cache layer when self-hosted Sentry
instances have malformed base URLs.
### Bug (CLI-GC — 3 events, 1 user)
`getCachedResponse()` and `storeCachedResponse()` both call
`buildCacheKey()` — which internally runs `new URL(url)` — **outside**
their try-catch guards. On self-hosted instances with malformed base
URLs, this throws `TypeError: Invalid URL`, crashing the entire command
before the actual API request even fires.
### Fix
Guard the `buildCacheKey()` call in both functions. When the URL can't
be parsed:
- **Cache lookup**: skip and return `undefined` (treat as cache miss)
- **Cache store**: skip silently (response was already returned to the
caller)
The actual `fetch()` call will surface the real error if the URL is
truly broken — the cache layer shouldn't be the one to crash.
`normalizeUrl()` itself **still throws** on invalid URLs (correct
behavior for a low-level utility) — the callers handle the failure since
caching is non-essential infrastructure.
### Tests added
- `normalizeUrl()` throws on invalid URL (verifies it doesn't silently
swallow)
- `getCachedResponse()` returns undefined for malformed URLs (no crash)
- `storeCachedResponse()` completes without throwing for malformed URLs
1 parent bc6c5fc commit 7db4f7c
2 files changed
+70
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
370 | | - | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
371 | 380 | | |
372 | 381 | | |
373 | 382 | | |
| |||
467 | 476 | | |
468 | 477 | | |
469 | 478 | | |
470 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
471 | 486 | | |
472 | 487 | | |
473 | 488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
266 | 298 | | |
267 | 299 | | |
268 | 300 | | |
| |||
286 | 318 | | |
287 | 319 | | |
288 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
289 | 342 | | |
290 | 343 | | |
291 | 344 | | |
| |||
0 commit comments