Skip to content

fix(issue): improve resolution errors for short ID and org/project confusion#1205

Closed
betegon wants to merge 10 commits into
mainfrom
fix/cli-a0-dx-improvements
Closed

fix(issue): improve resolution errors for short ID and org/project confusion#1205
betegon wants to merge 10 commits into
mainfrom
fix/cli-a0-dx-improvements

Conversation

@betegon

@betegon betegon commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • Report Issue 'PROJECT-SUFFIX' not found instead of Project 'slug' not found when issue short ID resolution fails after fan-out (CLI-A0 agent confusion).
  • Reject issue-1-style args early with a ValidationError when the dash prefix is a CLI resource noun (issue, trace, etc.).
  • Add case-insensitive looksLikeIssueShortId for issue list auto-recovery and list-command short ID detection.
  • Improve org/numeric-id 404 messages to explain slugs vs numeric project IDs.

Test plan

  • vitest run test/lib/arg-parsing.test.ts test/lib/arg-parsing.property.test.ts test/lib/resolve-target.test.ts test/commands/issue/utils.test.ts
  • bun run lint:fix && bun run typecheck
  • sentry issue explain issue-1 → ValidationError with correct format hints
  • sentry issue view fakeproj-1b → Issue not found (not Project not found)

Made with Cursor

…nfusion

When issue short ID lookup fails, report the issue ID as not found instead
of a misleading project slug error. Add guards for command-noun misparsing
(issue-1), case-insensitive short ID recovery, and numeric project hints.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 7, 2026
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1205/

Built to branch gh-pages at 2026-07-08 11:26 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/commands/issue/list.ts Outdated
Comment thread src/lib/arg-parsing.ts Outdated
betegon and others added 2 commits July 7, 2026 19:44
…positives

Only apply case-insensitive matching when the input already contains
uppercase letters or has three+ dash segments, so project slugs like
acme-corp and my-project are not misclassified as issue short IDs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use validationError() for command-noun guard, extract ignoreCase matching,
and dedupe displaySlug in resolve-target project-search handling.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/lib/arg-parsing.ts
Comment thread src/lib/arg-parsing.ts Outdated
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

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

Files with missing lines (2)
File Patch % Lines
src/lib/arg-parsing.ts 100.00% ⚠️ 1 partials
src/lib/resolve-target.ts 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.82%    81.87%    +0.05%
==========================================
  Files          423       423         —
  Lines        29354     29396       +42
  Branches     19124     19152       +28
==========================================
+ Hits         24017     24066       +49
- Misses        5337      5330        -7
- Partials      1986      1986         —

Generated by Codecov Action

Only block CLI resource nouns with numeric suffixes (issue-1), and require
a digit in the final segment for lowercase multi-part short ID recovery
so project slugs like my-frontend-app are not misclassified.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/lib/arg-parsing.ts Outdated
Apply the same issue-1 ValidationError in parseAfterSlash so my-org/issue-1
no longer bypasses the bare issue-1 guard. Extract shared helper and update
Try hints to use the org/project/suffix form.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/lib/arg-parsing.ts Outdated
Only block numeric-suffix dash args when the project segment is the issue
command token, not all CLI resource nouns. Restores api-1 and release-123
for projects with those slugs while keeping issue-1 agent misparsing guard.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/commands/issue/list.ts
betegon and others added 2 commits July 8, 2026 12:45
For ignoreCase matching, require multi-segment lowercase finals to contain
both a letter and a digit so slugs like my-app-2 are not misrouted as
issue short IDs in issue list auto-recovery.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rename issue command token helpers for accuracy, extract isAlphanumericSegment,
expand ignoreCase JSDoc, and align test/docs labels with narrowed guard scope.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/commands/issue/list.ts
Comment thread src/lib/arg-parsing.ts
Comment thread src/commands/issue/list.ts
Apply multi-segment slug guards using lowercased final segments so title-case
project names no longer match ignoreCase short IDs, and reject issue-1-style
list targets before parseOrgProjectArg treats them as project slugs.

Co-authored-by: Cursor <cursoragent@cursor.com>

@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 6d9ec3e. Configure here.

Comment thread src/commands/issue/list.ts Outdated
Use parsed.projectSlug for short-ID detection so `/CLI-G` matches bare
`CLI-G` after parseOrgProjectArg strips the leading slash.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/lib/arg-parsing.ts
Comment on lines +149 to +155
}
if (multiSegment) {
const lastPartLower = (parts.at(-1) ?? "").toLowerCase();
if (!isAlphanumericSegment(lastPartLower)) {
return false;
}
}

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.

Bug: The matchesIssueShortIdIgnoreCase function incorrectly identifies two-part title-case strings like My-2 as issue short IDs because a validation check is only applied to inputs with three or more parts.
Severity: LOW

Suggested Fix

Modify the logic to apply the isAlphanumericSegment check to all mixed-case inputs, regardless of the number of segments, to correctly reject two-part title-case project slugs. Alternatively, update the function's documentation to clarify that the rejection guard only applies to slugs with three or more parts.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/lib/arg-parsing.ts#L149-L155

Potential issue: The function `matchesIssueShortIdIgnoreCase` incorrectly identifies
two-part, mixed-case strings that resemble project slugs (e.g., `My-2`) as valid issue
short IDs. The logic contains a guard to prevent this, but it only activates for inputs
with three or more segments. For a two-part input like `My-2`, the `multiSegment` check
evaluates to false, causing the `isAlphanumericSegment` validation to be skipped. The
input is then uppercased and tested against `ISSUE_SHORT_ID_PATTERN`, which it matches,
resulting in a false positive. This behavior contradicts the function's documentation,
which states that title-case project slugs are rejected.

Also affects:

  • src/commands/issue/list.ts:1519~1530
  • src/lib/resolve-target.ts:1920~1928

@betegon

betegon commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Closing this in favor of 4 focused PRs, one per independent improvement from the original CLI-A0 plan. Three of the four (issue-not-found message, command-noun guard, numeric-project-ID hint) were clean with zero review churn; the case-insensitive short-ID detection kept needing "just one more edge case" fix (10 commits, 7 of 12 review threads, 1 still open). Splitting lets the stable pieces ship immediately and isolates the messy heuristic for focused review, including a fix for the last open bug (My-2 title-case false positive).

Replacement PRs (links added once opened):

  1. Issue-not-found resolution error message
  2. Numeric project-ID 404 hint
  3. issue-1 command-noun guard
  4. Case-insensitive short-ID detection (with My-2 fix)

@betegon

betegon commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Replacement PRs:

  1. fix(issue): report issue not found instead of project not found #1207 — Issue-not-found resolution error message + docs bundle
  2. fix(resolve-target): hint numeric project IDs in 404 suggestions #1208 — Numeric project-ID 404 hint
  3. fix(issue): reject issue-1-style command-token args #1209 — issue-1 command-noun guard
  4. fix(issue): case-insensitive short-ID detection for issue list recovery #1210 — Case-insensitive short-ID detection (fixes the My-2 bug still open here)

betegon added a commit that referenced this pull request Jul 8, 2026
## Summary

Split out from #1205 (closed in favor of 4 focused PRs — see that PR for
context).

- Report `Issue 'PROJECT-SUFFIX' not found` instead of `Project 'slug'
not found` when issue short-ID resolution fails after fan-out (CLI-A0
agent confusion — see
[issue](https://sentry.sentry.io/issues/7297183155/)).
- Bundle the "Common mistakes" docs section covering all 4 split PRs'
guidance, so agents get the full picture immediately.

## Test plan

- [x] `vitest run test/commands/issue/utils.test.ts`
- [x] `bun run lint:fix && bun run typecheck`
- [ ] `sentry issue view fakeproj-1b` → `Issue 'FAKEPROJ-1B' not found`
(not `Project 'fakeproj' not found`)

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant