Skip to content

Commit c8ee923

Browse files
committed
fix: avoid double-prefixing in buildCommandHint for slashed args (CLI-8C)
When users pass org-prefixed issue args like `saber-ut/103103195`, buildCommandHint would add another `<org>/` prefix, producing nonsensical hints like `sentry issue view <org>/saber-ut/103103195`. Fix: detect when the input already contains a slash and show it as-is, since the user already provided the org/project context. Fixes CLI-8C (50 events, 8 users).
1 parent 5e5a4e6 commit c8ee923

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/commands/issue/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const issueIdPositional = {
6363
* Build a command hint string for error messages.
6464
*
6565
* Returns context-aware hints based on the issue ID format:
66+
* - Already contains `/` (e.g., "saber-ut/103103195") → show as-is (already has context)
6667
* - Numeric ID (e.g., "123456789") → suggest `<org>/123456789`
6768
* - Suffix only (e.g., "G") → suggest `<project>-G`
6869
* - Has dash (e.g., "cli-G") → suggest `<org>/cli-G`
@@ -75,6 +76,10 @@ export function buildCommandHint(command: string, issueId: string): string {
7576
if (issueId.startsWith("@")) {
7677
return `sentry issue ${command} <org>/${issueId}`;
7778
}
79+
// Input already contains org/project context — show as-is to avoid double-prefixing
80+
if (issueId.includes("/")) {
81+
return `sentry issue ${command} ${issueId}`;
82+
}
7883
// Numeric IDs always need org context - can't be combined with project
7984
if (isAllDigits(issueId)) {
8085
return `sentry issue ${command} <org>/${issueId}`;

test/commands/issue/utils.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ describe("buildCommandHint", () => {
5656
"sentry issue explain <org>/@most_frequent"
5757
);
5858
});
59+
60+
test("shows as-is when input already contains a slash (CLI-8C)", () => {
61+
// org/numeric — don't add another <org>/ prefix
62+
expect(buildCommandHint("view", "saber-ut/103103195")).toBe(
63+
"sentry issue view saber-ut/103103195"
64+
);
65+
// org/project-suffix — already has full context
66+
expect(buildCommandHint("view", "sentry/cli-G")).toBe(
67+
"sentry issue view sentry/cli-G"
68+
);
69+
// org/project/suffix — three-level path, show as-is
70+
expect(buildCommandHint("explain", "sentry/cli/CLI-A1")).toBe(
71+
"sentry issue explain sentry/cli/CLI-A1"
72+
);
73+
});
5974
});
6075

6176
const getConfigDir = useTestConfigDir("test-issue-utils-", {

0 commit comments

Comments
 (0)