Commit 6f1d9e3
authored
fix(project-create): preserve ApiError type so 4xx errors are silenced (#775)
## Summary
Fix [CLI-196](https://sentry.sentry.io/issues/7420270756/) where
`project create` failures were being captured as Sentry issues even for
user-permission errors (17 events from 5 users across 5 orgs in 24h).
## Root cause
`createProjectWithErrors` catches `ApiError` from
`createProjectWithDsn`. For unhandled status codes, it was wrapping in a
generic `CliError`:
```ts
throw new CliError(
`Failed to create project '${name}' in ${orgSlug}.\n\n` +
`API error (${error.status}): ${error.detail ?? error.message}`
);
```
This **loses the `status` field**. `classifySilenced` in
`error-reporting.ts` only silences `ApiError` with status 401–499, so
403 "Your organization has disabled this feature for members" became a
Sentry issue.
## Fix
Re-throw as `ApiError` preserving `status`/`detail`/`endpoint`.
User-facing output is unchanged (`ApiError` extends `CliError` and
`.format()` renders the wrapped message). The 4xx silencing now applies
— 403s go to the `cli.error.silenced` metric with org/user context, not
to Sentry as noisy issues. 5xx and network errors (status 0) continue to
be captured as legitimate signals.
Test updated to assert the preserved `ApiError` type and `status: 403`.1 parent c7643e5 commit 6f1d9e3
2 files changed
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | | - | |
260 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
261 | 271 | | |
262 | 272 | | |
263 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
| 420 | + | |
421 | 421 | | |
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
429 | 429 | | |
430 | | - | |
431 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
432 | 436 | | |
433 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
434 | 442 | | |
435 | 443 | | |
436 | 444 | | |
| |||
0 commit comments