Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(event): recognize numeric issue IDs and bare 'latest' in 'event view' - #1297

Merged
BYK merged 2 commits into
mainfrom
seer/fix/event-view-id-parsing
Jul 28, 2026
Merged

BYK merged 2 commits into
mainfrom
seer/fix/event-view-id-parsing

Conversation

@sentry

@sentry sentry Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

This PR addresses issue CLI-1F5 where sentry event view failed with a ValidationError: Invalid event ID "17370" when users provided numeric issue IDs (e.g., "17370") or the bare string "latest" (without the "@" prefix) as event identifiers.

The root cause was that parseSingleArg and parsePositionalArgs in src/commands/event/view.ts did not have specific handling for these valid, non-hexadecimal inputs, causing them to be incorrectly passed to hex validation.

Changes made:

  • Modified parseSingleArg and parsePositionalArgs to detect all-digit strings (numeric issue IDs) and the bare string "latest".
  • Numeric issue IDs are now correctly mapped to the issueId field and LATEST_EVENT_SENTINEL, routing them to the existing getLatestEvent logic.
  • The bare string "latest" is now mapped to LATEST_EVENT_SENTINEL.
  • Refactored the regex for detecting all-digit strings to use the existing isAllDigits utility function from src/lib/utils.ts, resolving a Biome linting error (lint/performance/useTopLevelRegex).

Fixes CLI-1F5

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-28 11:32 UTC

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 93.75%. Project has 5484 uncovered lines.
✅ Project coverage is 81.58%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/commands/event/view.ts 93.75% ⚠️ 2 Missing and 3 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.55%    81.58%    +0.03%
==========================================
  Files          428       428         —
  Lines        29744     29764       +20
  Branches     19486     19507       +21
==========================================
+ Hits         24256     24280       +24
- Misses        5488      5484        -4
- Partials      2031      2031         —

Generated by Codecov Action

Comment thread src/commands/event/view.ts Resolved
@sentry sentry Bot changed the title fix(event): recognize numeric issue IDs and bare 'latest' in view command fix(event view): recognize numeric issue IDs and bare "latest" Jul 25, 2026
@sentry
sentry Bot marked this pull request as ready for review July 25, 2026 11:59
Comment thread src/commands/event/view.ts Resolved
Comment thread src/commands/event/view.ts Resolved
Comment thread src/commands/event/view.ts Resolved
@BYK BYK added the jared Trigger the Jared agent to work on stuff label Jul 27, 2026
@MathurAditya724

Copy link
Copy Markdown
Member

Jared resolve all these review comments

@jared-outpost

jared-outpost Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Resolved the review comments in 489a343.

  • Numeric issue IDs skipped org resolution (Cursor, Seer): the issueId path resolved org via resolveEffectiveOrg("") which returns "", so bare sentry event view 17370 still failed. It now resolves the org through resolveOrg (env/config/DSN auto-detect) and honors an explicit org from org/project / org/ targets.
  • Bare latest fell through to a broken lookup (Warden, Cursor): latest was mapped to the @latest sentinel with no issue context and reached getEvent(org, project, "@latest"), which the project-events API doesn't support (there's no latest-event-for-a-project endpoint). It now throws a ContextError pointing at a numeric issue ID or issue short ID.

Added parsing + func-level tests covering both paths.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Reviewed by Cursor Bugbot for commit 489a343. Configure here.

Comment thread src/commands/event/view.ts Resolved
Comment thread src/commands/event/view.ts Resolved
@sentry sentry Bot changed the title fix(event view): recognize numeric issue IDs and bare "latest" fix(event): recognize numeric issue IDs and bare 'latest' in 'event view' Jul 28, 2026
@sentry
sentry Bot force-pushed the seer/fix/event-view-id-parsing branch from a209156 to 44fdd0b Compare July 28, 2026 10:29
Re-applies the review fixes for #1297 on top of the latest autofix push:

- Bare "latest" (with or without an explicit project) now throws a
  ContextError instead of mapping to the @latest sentinel with no issue
  to key on. There is no "latest event of a project" endpoint, so the
  old path fell through to getEvent(org, project, "@latest") and 404'd
  with a confusing "Event '@latest' not found" (Warden/Cursor).
- The numeric-issue-ID path resolves the org via resolveOrg (env/config/
  DSN auto-detect, plus explicit org/ and org/project targets) instead of
  resolveEffectiveOrg(""), which skipped auto-detection (Cursor).
- Handle "org/<numeric-issue-id>" single-slash form (e.g. my-org/17370),
  matching bare "17370", "org/project 17370", and 'sentry issue view'.
- Reuse the existing isAllDigits helper instead of a local regex (BYK).

parseSingleArg's single-slash matching is extracted into
parseSingleSlashArg and the issue-ID branch into resolveIssueIdShortcut
to stay under the cognitive-complexity limit. Adds parsing + func tests.
@jared-outpost

jared-outpost Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Heads-up on branch state: my earlier fixes (commit 489a343) were dropped when the branch was force-pushed by autofix, so those review threads showed as resolved while the bugs were actually back in the code. I've re-applied all of them on top of the current tip in e4e0ecb:

  • bare latest (with or without a project) now throws a ContextError instead of falling through to getEvent(org, project, "@latest"), which 404'd — there's no "latest event of a project" endpoint, latest is only resolvable per-issue (Warden/Cursor)
  • numeric issue IDs resolve the org via resolveOrg (env/config/DSN auto-detect + explicit org/ / org/project) instead of resolveEffectiveOrg("") (Cursor)
  • added org/<numeric-issue-id> single-slash handling, e.g. my-org/17370 (Cursor)
  • reuses the existing isAllDigits helper (BYK)

typecheck, biome, and vitest are green (114 tests). Note this branch is autofix-owned and has been force-pushed several times — if it gets reset again these fixes will need re-applying.

@BYK
BYK merged commit e810882 into main Jul 28, 2026
32 checks passed
@BYK
BYK deleted the seer/fix/event-view-id-parsing branch July 28, 2026 11:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

jared Trigger the Jared agent to work on stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants