Skip to content

fix: reject @-selectors in parseOrgProjectArg with helpful redirect#557

Merged
BYK merged 1 commit intomainfrom
byk/fix-at-selector-in-list-commands
Mar 25, 2026
Merged

fix: reject @-selectors in parseOrgProjectArg with helpful redirect#557
BYK merged 1 commit intomainfrom
byk/fix-at-selector-in-list-commands

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 25, 2026

Fixes CLI-MH: ResolutionError: Project '@latest' not found.

A user ran sentry issues @latest expecting the @latest magic selector to work. However, @latest is only recognized by parseIssueArg() (used in issue view/explain/plan), not by parseOrgProjectArg() (used in list commands). Since @ was not in RESOURCE_ID_FORBIDDEN, it passed validation, entered project-search mode, and produced a confusing "Project '@latest' not found" error.

Fix

Added rejectAtSelector() in src/lib/arg-parsing.ts that catches @-prefixed values before they reach project resolution:

  • Known selectors (@latest, @most_frequent) → ValidationError with redirect: Use: sentry issue view @latest
  • Unknown @-prefixed valuesValidationError: slugs don't start with @

Applied in three locations:

  1. parseOrgProjectArg() bare-slug branch (@latest)
  2. parseSlashOrgProject() leading-slash branch (/@latest)
  3. parseSlashOrgProject() explicit org branch (sentry/@latest)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 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) Rich terminal chart rendering for dashboard view by BYK in #555
  • (formatters) Colorize SQL in DB span descriptions by BYK in #546
  • (init) Treat bare slug as new project name when not found by BYK in #554
  • 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 🐛

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

@BYK BYK force-pushed the byk/fix-at-selector-in-list-commands branch from 1dd29a1 to e21717c Compare March 25, 2026 11:02
@BYK BYK marked this pull request as ready for review March 25, 2026 11:03
@github-actions
Copy link
Copy Markdown
Contributor

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

Files with missing lines (1)
File Patch % Lines
arg-parsing.ts 95.09% ⚠️ 19 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    95.32%    95.32%        —%
==========================================
  Files          194       194         —
  Lines        27279     27300       +21
  Branches         0         0         —
==========================================
+ Hits         26002     26023       +21
- Misses        1277      1277         —
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK force-pushed the byk/fix-at-selector-in-list-commands branch from e21717c to 9354dc7 Compare March 25, 2026 11:15
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.

Fixes CLI-MH: 'Project @latest not found' when running 'sentry issues @latest'.

The @latest and @most_frequent magic selectors are only valid for
parseIssueArg (issue view/explain/plan), not for parseOrgProjectArg
(list commands). Previously, @ was not in RESOURCE_ID_FORBIDDEN so
'@latest' passed validation and entered project-search mode, leading
to a confusing ResolutionError.

Add rejectAtSelector() guard in:
- parseOrgProjectArg() bare-slug branch
- parseSlashOrgProject() both project slug branches (/@latest, org/@latest)

Known selectors get a redirect: 'Use: sentry issue view @latest'
Unknown @-prefixed values get: 'starts with @, slugs use letters/numbers/hyphens'
@BYK BYK force-pushed the byk/fix-at-selector-in-list-commands branch from 9354dc7 to 3f84527 Compare March 25, 2026 11:21
@BYK BYK merged commit 946190f into main Mar 25, 2026
22 checks passed
@BYK BYK deleted the byk/fix-at-selector-in-list-commands branch March 25, 2026 11:30
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