Skip to content

fix(telemetry): skip Sentry reporting for 4xx API errors#251

Merged
BYK merged 3 commits intomainfrom
fix/skip-4xx-telemetry
Feb 16, 2026
Merged

fix(telemetry): skip Sentry reporting for 4xx API errors#251
BYK merged 3 commits intomainfrom
fix/skip-4xx-telemetry

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 16, 2026

Summary

  • Skip captureException and markSessionCrashed for 4xx ApiErrors (user errors like wrong IDs, no access)
  • Record 4xx errors as span attributes (api_error.status, api_error.message, api_error.detail) for volume-spike detection in Discover
  • Extract isClientApiError() helper following the same pattern as isEpipeError()

Motivation

CLI-5M and CLI-46 are ApiError: 404 Not Found from users passing non-existent issue/event IDs. These are expected operational errors, not bugs, but they were polluting the Sentry issue stream.

Approach

Instead of dropping these errors entirely, they're recorded as span attributes so they remain queryable in Discover without creating issues:

api_error.status:*     # all 4xx errors
api_error.status:404   # specifically 404s

A regression (e.g., broken API URL causing mass 404s) would show as a volume spike in span queries.

What's unchanged

  • 5xx ApiErrors → still reported as exceptions
  • AuthError("not_authenticated") → still skipped (existing behavior)
  • Errors still propagate to bin.ts for user-facing formatting

Fixes CLI-5M, CLI-46

@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Build

  • Add hole-punch tool to reduce compressed binary size by BYK in #245
  • Add gzip-compressed binary downloads by BYK in #244

Bug Fixes 🐛

Telemetry

  • Skip Sentry reporting for 4xx API errors by BYK in #251
  • Handle EPIPE errors from piped stdout gracefully by BYK in #250
  • Upgrade Sentry SDK to 10.39.0 and remove custom patches by BYK in #249

Other

  • (polyfill) Add exited promise and stdin to Bun.spawn Node.js polyfill by BYK in #248
  • (upgrade) Remove v prefix from release URLs and work around Bun.write streaming bug by BYK in #243

Internal Changes 🔧

  • (build) Replace local hole-punch script with binpunch package by BYK in #246
  • Use @sentry/api client for requests by MathurAditya724 in #226

🤖 This preview updates automatically when you update the PR.

@BYK BYK force-pushed the fix/skip-4xx-telemetry branch from aa91c11 to f3a6c61 Compare February 16, 2026 21:36
@BYK BYK marked this pull request as ready for review February 16, 2026 21:37
@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2026

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 4094 uncovered lines.
✅ Project coverage is 68.51%. Comparing base (base) to head (head).

Files with missing lines (71)
File Patch % Lines
human.ts 58.29% ⚠️ 395 Missing
resolve-target.ts 20.26% ⚠️ 366 Missing
list.ts 14.39% ⚠️ 345 Missing
api-client.ts 59.38% ⚠️ 262 Missing
list.ts 23.47% ⚠️ 212 Missing
oauth.ts 30.68% ⚠️ 183 Missing
list.ts 21.96% ⚠️ 167 Missing
plan.ts 19.37% ⚠️ 154 Missing
resolver.ts 3.23% ⚠️ 120 Missing
help.ts 19.85% ⚠️ 109 Missing
upgrade.ts 61.37% ⚠️ 107 Missing
view.ts 36.48% ⚠️ 101 Missing
interactive-login.ts 9.17% ⚠️ 99 Missing
errors.ts 5.94% ⚠️ 95 Missing
view.ts 25.81% ⚠️ 92 Missing
view.ts 39.44% ⚠️ 86 Missing
clipboard.ts 4.49% ⚠️ 85 Missing
status.ts 24.07% ⚠️ 82 Missing
migration.ts 47.44% ⚠️ 82 Missing
list.ts 27.18% ⚠️ 75 Missing
browser.ts 4.11% ⚠️ 70 Missing
login.ts 33.33% ⚠️ 64 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
explain.ts 33.33% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
upgrade.ts 66.91% ⚠️ 46 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
refresh.ts 40.63% ⚠️ 38 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
view.ts 87.27% ⚠️ 28 Missing
utils.ts 88.94% ⚠️ 25 Missing
view.ts 61.54% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
binary.ts 88.67% ⚠️ 17 Missing
list.ts 91.16% ⚠️ 16 Missing
list.ts 90.70% ⚠️ 16 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
help.ts 57.14% ⚠️ 15 Missing
telemetry.ts 95.60% ⚠️ 14 Missing
sentry-client.ts 92.22% ⚠️ 13 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
logout.ts 56.00% ⚠️ 11 Missing
token.ts 52.17% ⚠️ 11 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
view.ts 94.70% ⚠️ 7 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.76% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
shell.ts 96.23% ⚠️ 6 Missing
app.ts 93.90% ⚠️ 5 Missing
region.ts 86.49% ⚠️ 5 Missing
setup.ts 97.84% ⚠️ 4 Missing
list.ts 97.33% ⚠️ 4 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
output.ts 89.47% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
completions.ts 99.37% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 98.21% ⚠️ 1 Missing
trace.ts 99.16% ⚠️ 1 Missing
helpers.ts 97.62% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    68.18%    68.51%    +0.33%
==========================================
  Files          108       109        +1
  Lines        12978     13002       +24
  Branches         0         0         —
==========================================
+ Hits          8849      8908       +59
- Misses        4129      4094       -35
- Partials         0         0         —

Generated by Codecov Action

4xx API errors (404 Not Found, 403 Forbidden, etc.) are user errors —
wrong IDs, missing access — not CLI bugs. Recording them as exceptions
creates noise in the Sentry issue stream without being actionable.

Instead of capturing these as exceptions, record them as span attributes
(api_error.status, api_error.message, api_error.detail) so they remain
queryable in Discover for volume-spike detection without polluting the
error feed.

Extract isClientApiError() helper for classifying 4xx errors, following
the same pattern as the existing isEpipeError() helper.

Fixes CLI-5M
Fixes CLI-46
@BYK BYK force-pushed the fix/skip-4xx-telemetry branch from f3a6c61 to ef285ce Compare February 16, 2026 21:50
BYK added 2 commits February 16, 2026 22:07
The 'with telemetry enabled' tests call initSentry(true) which sets global
SDK state. Without cleanup, Sentry.isEnabled() returns true for all subsequent
test files, breaking feedbackCommand's telemetry-disabled assertion.
@BYK BYK merged commit 4bb74cf into main Feb 16, 2026
23 checks passed
@BYK BYK deleted the fix/skip-4xx-telemetry branch February 16, 2026 22:17
BYK added a commit that referenced this pull request Feb 17, 2026
…ailures

When all project fetches fail, re-throw the original ApiError (with
status, detail, endpoint) instead of a plain Error. This lets the
telemetry layer in PR #251 correctly classify 4xx errors as client
errors and suppress them from Sentry exceptions.

Also:
- Classify more HTTP status codes (404, 429, other 4xx) instead of
  lumping everything into "unknown"
- Include partial failure info in JSON output when some projects fail
- Warn on stderr about partial failures in human output
- Add tests for error propagation and partial failure handling
BYK added a commit that referenced this pull request Feb 17, 2026
…ailures

When all project fetches fail, re-throw the original ApiError (with
status, detail, endpoint) instead of a plain Error. This lets the
telemetry layer in PR #251 correctly classify 4xx errors as client
errors and suppress them from Sentry exceptions.

Also:
- Classify more HTTP status codes (404, 429, other 4xx) instead of
  lumping everything into "unknown"
- Include partial failure info in JSON output when some projects fail
- Warn on stderr about partial failures in human output
- Add tests for error propagation and partial failure handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant