Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 3, 2026

Summary

Replace explicit --org and --project flags with a more intuitive positional syntax for issue commands (view, explain, plan).

Closes CLI-16 - User got unhelpful error when running sentry issue view EXTENSION-7 without org context.

New Issue ID Formats

Format Example Description
<org>/ID sentry/EXTENSION-7 Explicit org prefix
<project>-suffix cli-G Searches for project across orgs
suffix G Requires DSN context for project
numeric 123456789 Direct fetch by numeric ID

Resolution Logic

  1. Alias cache - Fast local lookup from previous issue list results
  2. Project search - Search for project slug across all accessible orgs
  3. DSN detection - Use detected DSN for project context (suffix-only)

Examples

# Before (required explicit flags)
sentry issue view EXTENSION-7 --org sentry

# After (intuitive prefix syntax)
sentry issue view sentry/EXTENSION-7

# Or let CLI search for project
sentry issue view cli-G

Changes

  • src/commands/issue/{view,explain,plan}.ts - Updated to use new syntax
  • src/commands/issue/utils.ts - New resolution logic with findProjectsBySlug()
  • src/lib/issue-id.ts - New parsing functions for issue ID formats
  • test/commands/issue/utils.test.ts - Updated tests for new API

Replace explicit --org and --project flags with a more intuitive positional
syntax for issue commands (view, explain, plan).

New issue ID formats:
- <org>/ID: Explicit org prefix (e.g., sentry/EXTENSION-7)
- <project>-suffix: Project + suffix (e.g., cli-G) - searches across orgs
- suffix: Short suffix only (e.g., G) - requires DSN context
- numeric: Direct fetch by numeric ID (e.g., 123456789)

Resolution logic:
1. Alias cache lookup (fast, local)
2. Project search across accessible orgs
3. DSN detection for project context

Closes CLI-16
@linear
Copy link

linear bot commented Feb 3, 2026

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 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 ✨

  • (issue) Replace --org/--project flags with /ID syntax by BYK in #161

Bug Fixes 🐛

  • Added nullable in substatus's zod validation by MathurAditya724 in #157

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

Codecov Results 📊

✅ Patch coverage is 85.57%. Project has 2022 uncovered lines.
❌ Project coverage is 69.2%. Comparing base (base) to head (head).

Files with missing lines (29)
File Patch % Lines
human.ts 31.87% ⚠️ 682 Missing
resolve-target.ts 10.74% ⚠️ 291 Missing
oauth.ts 25.10% ⚠️ 194 Missing
upgrade.ts 39.76% ⚠️ 153 Missing
api-client.ts 74.21% ⚠️ 138 Missing
resolver.ts 3.23% ⚠️ 120 Missing
errors.ts 5.94% ⚠️ 95 Missing
migration.ts 47.44% ⚠️ 82 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 39.02% ⚠️ 25 Missing
utils.ts 87.43% ⚠️ 24 Missing
version-check.ts 76.00% ⚠️ 18 Missing
detector.ts 87.79% ⚠️ 16 Missing
schema.ts 64.10% ⚠️ 14 Missing
auth.ts 94.78% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
arg-parsing.ts 93.41% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
index.ts 95.06% ⚠️ 4 Missing
colors.ts 91.84% ⚠️ 4 Missing
telemetry.ts 97.20% ⚠️ 4 Missing
env-file.ts 97.17% ⚠️ 3 Missing
sentry-urls.ts 88.00% ⚠️ 3 Missing
alias.ts 98.56% ⚠️ 2 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
java.ts 97.22% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    69.68%    69.20%    -0.48%
==========================================
  Files           56        57        +1
  Lines         6462      6565      +103
  Branches         0         0         —
==========================================
+ Hits          4503      4543       +40
- Misses        1959      2022       +63
- Partials         0         0         —

Generated by Codecov Action

@BYK
Copy link
Member Author

BYK commented Feb 3, 2026

Good question! While both functions share the "split on slash" pattern for org prefix, they serve different purposes with different downstream handling:

parseOrgProjectArg (from PR #155) - For issue list, project list:

  • Parses a target location: org/project, org/, project, or auto-detect
  • The "rest" after slash is a project slug
  • Handles cases like sentry/ (all projects in org)

parseIssueArg (this PR) - For issue view, explain, plan:

  • Parses an issue identifier: org/issue-id, project-suffix, suffix, or numeric
  • The "rest" after slash is an issue ID that needs further parsing (numeric check, dash detection, suffix detection)
  • Handles cases like 123456789 (numeric ID), cli-G (project-suffix), G (suffix only)

The only overlap is the 3-line slash detection. Merging them would mix concerns and require callers to handle cases they don't care about. I think keeping them separate is cleaner.

That said, if you'd prefer, I could extract a tiny extractOrgPrefix(arg: string): { org: string; rest: string } | null helper that both functions use. Let me know!

Extract shared org/project parsing logic into src/lib/arg-parsing.ts:
- Move parseOrgProjectArg from resolve-target.ts
- Refactor parseIssueArg to use parseOrgProjectArg for left part of dash-separated inputs
- Flatten ParsedIssueArg types for better ergonomics

New parseIssueArg flow:
1. Split on last '-' to get (leftPart, suffix)
2. Pass leftPart through parseOrgProjectArg
3. Combine with suffix into flattened result types

This consolidates the org/project parsing pattern used by both
issue list (org/project targets) and issue view/explain/plan (issue IDs).
@BYK
Copy link
Member Author

BYK commented Feb 3, 2026

Done! I've consolidated the parsing logic as suggested in commit c21779b:

New structure:

  • Created src/lib/arg-parsing.ts with shared parsing logic
  • parseIssueArg now uses parseOrgProjectArg internally for the left part of dash-separated inputs
  • Flattened ParsedIssueArg types for better ergonomics

Flow for cli-G or sentry/cli-G:

  1. Split on last -(cli, G) or (sentry/cli, G)
  2. Pass left part through parseOrgProjectArg{type: project-search} or {type: explicit}
  3. Combine with suffix → flattened result

Invalid combinations rejected at parse time:

  • sentry/-G (org-all + suffix) → Error
  • -G (auto-detect + suffix) → Error

This consolidates the org/project parsing pattern used by both listing commands and single-item commands.

@BYK BYK marked this pull request as ready for review February 3, 2026 19:52
- Remove unused splitProjectSuffix function (dead code)
- Replace with isNumericId helper for detecting pure numeric IDs
- Fix buildCommandHint to suggest <org>/ID for numeric IDs instead of
  incorrectly suggesting <project>-ID
- Add tests for isNumericId and buildCommandHint
- Remove duplicate NUMERIC_ID_PATTERN, import isNumericId from issue-id.ts
- Remove ASCII-art style separator comment
- Add validation for empty suffixes (trailing dash like 'cli-')
- Add validation for missing issue ID after slash (like 'org/')
- Add tests for empty suffix error cases
Copy link

@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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

- Remove DSN fallback from resolveExplicitOrgSuffix - mixing explicit
  org with DSN-detected project (which belongs to a different org) is
  semantically wrong and confusing
- Add validation for empty project slug in parseOrgProjectArg ('/')
- Add test for '/' input throwing error
@BYK BYK merged commit 758b465 into main Feb 3, 2026
24 checks passed
@BYK BYK deleted the feat/issue-org-prefix-syntax branch February 3, 2026 21:19
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.

2 participants