Skip to content

fix(api): show meaningful message for network errors instead of '0 Unknown'#572

Merged
BYK merged 2 commits intomainfrom
fix/network-error-message
Mar 26, 2026
Merged

fix(api): show meaningful message for network errors instead of '0 Unknown'#572
BYK merged 2 commits intomainfrom
fix/network-error-message

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 26, 2026

Summary

When an API request fails at the network level (DNS failure, timeout, ECONNREFUSED, etc.), the response object is undefined. Previously, throwApiError() produced cryptic messages like:

Error: Failed to resolve short ID: 0 Unknown

This gives users no useful information about what went wrong.

Fix

Now it produces a meaningful message:

Error: Failed to resolve short ID: Network error
  Unable to reach Sentry API. Cause: fetch failed

  Check your internet connection and try again.

The detail includes the underlying cause (e.g., fetch failed, connect ECONNREFUSED 127.0.0.1:443) and a suggestion to check internet connectivity.

Sentry Issue

Fixes CLI-G3 (7 users, 35 events across 0.19.0/0.20.0)

Changes

  • src/lib/api/infrastructure.ts: Added network-failure detection in throwApiError() when response is undefined
  • test/lib/api/infrastructure.test.ts: New test file covering network errors, HTTP errors, and edge cases

…known'

When an API request fails at the network level (DNS failure, timeout,
ECONNREFUSED, etc.), the response object is undefined. Previously,
throwApiError() produced 'Failed to ...: 0 Unknown' which gives
users no useful information.

Now it produces 'Failed to ...: Network error' with a detail message
that includes the underlying cause (e.g., 'fetch failed',
'connect ECONNREFUSED 127.0.0.1:443') and a suggestion to check
internet connectivity.

Fixes CLI-G3 (7 users, 35 events across 0.19.0/0.20.0)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 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 ✨

Dashboard

  • Add pagination and glob filtering to dashboard list by BYK in #560
  • Rich terminal chart rendering for dashboard view by BYK in #555

Init

  • Propagate sentry-trace headers to wizard API calls by betegon in #567
  • Treat bare slug as new project name when not found by BYK in #554

Other

  • (formatters) Colorize SQL in DB span descriptions by BYK in #546
  • (telemetry) Report unknown commands to Sentry by BYK in #563
  • Bidirectional cursor pagination (-c next / -c prev) by BYK in #564
  • Add sentry sourcemap inject and sentry sourcemap upload commands by BYK in #547
  • Native debug ID injection and sourcemap upload by BYK in #543

Bug Fixes 🐛

Dashboard

  • Default issue dataset table columns to ["issue"] by betegon in #570
  • Scale timeseries bar width to fill chart area by BYK in #562
  • Resolve dashboard by ID/slug in addition to title by BYK in #559

Other

  • (api) Show meaningful message for network errors instead of '0 Unknown' by BYK in #572
  • (event-view) Auto-redirect issue short IDs in two-arg form (CLI-MP) by BYK in #558
  • (help) Show help when user passes help as positional arg by BYK in #561
  • Reject @-selectors in parseOrgProjectArg with helpful redirect by BYK in #557

Internal Changes 🔧

Coverage

  • Use informational-patch input instead of sed hack by BYK in #544
  • Make checks informational on release branches by BYK in #541

Other

  • (api) Collapse stats on issue detail endpoints to save 100-300ms by BYK in #551
  • (ci) Upgrade GitHub Actions to Node 24 runtime by BYK in #542
  • (db) DRY up database layer with shared helpers and lint enforcement by BYK in #550
  • (issue-list) Use collapse parameter to skip unused Snuba queries by BYK in #545
  • Bump Bun from 1.3.9 to 1.3.11 by BYK in #552
  • Regenerate skill files by github-actions[bot] in ec1ffe28

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

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

Files with missing lines (1)
File Patch % Lines
infrastructure.ts 99.53% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.43%    95.43%        —%
==========================================
  Files          194       194         —
  Lines        27894     27903        +9
  Branches         0         0         —
==========================================
+ Hits         26620     26629        +9
- Misses        1274      1274         —
- Partials         0         0         —

Generated by Codecov Action

Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

…rmat()

ApiError.format() only indents the first line of detail with '\n  '.
Continuation lines need explicit indentation to maintain the aligned
error layout.
@BYK
Copy link
Copy Markdown
Member Author

BYK commented Mar 26, 2026

Addressed Cursor Bugbot feedback: fixed the multi-line detail indentation for ApiError.format() in d193e66. The continuation line now has explicit \n\n indentation so it aligns correctly.

@BYK BYK merged commit 085b961 into main Mar 26, 2026
22 checks passed
@BYK BYK deleted the fix/network-error-message branch March 26, 2026 16:42
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