Skip to content

fix: enrich event 404 errors with retention and format suggestions (CLI-6F)#491

Merged
BYK merged 2 commits intomainfrom
fix/cli-6f-event-404
Mar 20, 2026
Merged

fix: enrich event 404 errors with retention and format suggestions (CLI-6F)#491
BYK merged 2 commits intomainfrom
fix/cli-6f-event-404

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 20, 2026

Problem

When sentry event view gets a 404 Not Found, the error shows:

ApiError: Failed to get event: 404 Not Found

This doesn't help users diagnose whether the event ID is wrong, the event was deleted due to data retention, or it belongs to a different project. Affects 54 users (CLI-6F).

Fix

Extracted event fetching into a fetchEventWithContext() helper that catches 404 errors and throws a ResolutionError with actionable suggestions:

Event 'abc123def456...' not found in my-org/my-project.

Try:
  sentry event view my-org/my-project <event-id>

Or:
  - The event may have been deleted due to data retention policies
  - Verify the event ID is a 32-character hex string (e.g., a1b2c3d4...)
  - Check if the event belongs to a different project: sentry event view my-org/ <event-id>

Design Decisions

  • Extracted into a separate function to avoid exceeding biome's cognitive complexity limit on func()
  • Only catches 404 errors — other API errors (403, 500) propagate unchanged
  • Reuses the existing ResolutionError pattern consistent with other commands
  • The trailing-slash suggestion (sentry event view my-org/ <event-id>) hints at org-wide search

…LI-6F)

When `sentry event view` gets a 404 Not Found, the generic
'Failed to get event: 404 Not Found' doesn't help users diagnose
the cause. This affects 54 users (CLI-6F).

Extracted event fetching into a fetchEventWithContext() helper that
catches 404 errors and throws a ResolutionError with suggestions:
- Data retention policies may have deleted the event
- Verify the event ID is a 32-char hex string
- Check if the event belongs to a different project

This also fixes the biome complexity lint by extracting the try-catch
into a separate function instead of adding it inline to func().
@github-actions
Copy link
Copy Markdown
Contributor

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

  • (telemetry) Track TTY vs non-TTY invocations via metric by betegon in #482
  • Dynamic cache-backed shell completions with fuzzy matching by BYK in #465

Bug Fixes 🐛

  • (project) Fallback to org listing when bare slug matches an organization by betegon in #475
  • Enrich event 404 errors with retention and format suggestions (CLI-6F) by BYK in #491
  • Add actionable suggestions for 400 Bad Request on issue list (CLI-BM, CLI-7B) by BYK in #489
  • Detect issue short IDs passed to issue list (CLI-C3) by BYK in #488
  • Add Glob.match() polyfill + improve auto-detect diagnostics (CLI-7T) by BYK in #487
  • Add org-slug pre-check to dispatchOrgScopedList (CLI-9A) by BYK in #485

Internal Changes 🔧

  • (issue) Skip getProject round-trip in project-search resolution by betegon in #473
  • (resolve) Carry project data through resolution to eliminate redundant getProject calls by BYK in #486
  • Switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) by BYK in #474
  • Regenerate skill files by github-actions[bot] in b7b240ec

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 20, 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 1037 uncovered lines.
✅ Project coverage is 95.78%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.78%    95.78%        —%
==========================================
  Files          180       180         —
  Lines        24566     24579       +13
  Branches         0         0         —
==========================================
+ Hits         23529     23542       +13
- Misses        1037      1037         —
- Partials         0         0         —

Generated by Codecov Action

1. Use actual eventId variable in hint and suggestions instead of placeholder
2. Use already-imported SentryEvent type instead of inline import()
Copy link
Copy Markdown

@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.

throw new ResolutionError(
`Event '${eventId}'`,
`not found in ${org}/${project}`,
`sentry event view ${org}/${project} ${eventId}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"Try" hint repeats the exact failing command

Low Severity

The hint parameter passed to ResolutionError is sentry event view ${org}/${project} ${eventId}, which is the exact command the user just ran that produced the 404. The buildResolutionMessage function renders this under a Try: heading, so the error message suggests retrying the identical failing command. Compare with the analogous ResolutionError in resolveOrgAllTarget, which uses a <project> placeholder to provide genuinely actionable guidance. The hint here could use a placeholder or point to a different resolution path instead.

Fix in Cursor Fix in Web

@BYK BYK merged commit 91124d3 into main Mar 20, 2026
22 checks passed
@BYK BYK deleted the fix/cli-6f-event-404 branch March 20, 2026 00:48
BYK added a commit that referenced this pull request Mar 20, 2026
…ing command

Address unresolved Bugbot review from PR #491: the 'Try:' hint in
fetchEventWithContext repeated the exact command that just failed.
Changed to use a <project> placeholder so it suggests trying a
different project, and updated the suggestion bullet to explicitly
say 'Search across all projects in the org'.
BYK added a commit that referenced this pull request Mar 20, 2026
…ing command (#492)

## Follow-up to PR #491

Addresses unresolved [Bugbot review
comment](#491 (comment))
that I missed before merging #491.

## Problem

The `Try:` hint in `fetchEventWithContext` repeated the exact command
that just produced the 404:

```
Event 'abc123' not found in my-org/my-project.

Try:
  sentry event view my-org/my-project abc123   ← same failing command!
```

## Fix

Changed the hint to use a `<project>` placeholder to suggest trying a
different project, and updated the `Or:` suggestion to explicitly
mention org-wide search:

```
Event 'abc123' not found in my-org/my-project.

Try:
  sentry event view my-org/<project> abc123     ← try a different project

Or:
  - The event may have been deleted due to data retention policies
  - Verify the event ID is a 32-character hex string (e.g., a1b2c3d4...)
  - Search across all projects in the org: sentry event view my-org/ abc123
```
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