fix(issue): improve resolution errors for short ID and org/project confusion#1205
fix(issue): improve resolution errors for short ID and org/project confusion#1205betegon wants to merge 10 commits into
Conversation
…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>
|
…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>
Codecov Results 📊✅ Patch coverage is 100.00%. Project has 5330 uncovered lines. Files with missing lines (2)
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>
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>
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>
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>
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.
| } | ||
| if (multiSegment) { | ||
| const lastPartLower = (parts.at(-1) ?? "").toLowerCase(); | ||
| if (!isAlphanumericSegment(lastPartLower)) { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
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~1530src/lib/resolve-target.ts:1920~1928
|
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 ( Replacement PRs (links added once opened):
|
|
Replacement PRs:
|
## 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>

Summary
Issue 'PROJECT-SUFFIX' not foundinstead ofProject 'slug' not foundwhen issue short ID resolution fails after fan-out (CLI-A0 agent confusion).issue-1-style args early with aValidationErrorwhen the dash prefix is a CLI resource noun (issue,trace, etc.).looksLikeIssueShortIdforissue listauto-recovery and list-command short ID detection.org/numeric-id404 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.tsbun run lint:fix && bun run typechecksentry issue explain issue-1→ ValidationError with correct format hintssentry issue view fakeproj-1b→ Issue not found (not Project not found)Made with Cursor