Skip to content

Commit a266720

Browse files
authored
fix: lowercase project slug in URL-parsed issue short IDs (CLI-C8 follow-up) (#506)
## Follow-up to PR #496 Addresses unresolved [Bugbot review comment](#496 (comment)) (High severity) that was missed before merging #496. ## Problem `issueArgFromUrl` returned the project slug without `.toLowerCase()` when parsing Sentry issue URLs like: ``` https://sentry.io/organizations/my-org/issues/CLI-G/ ``` This produced `project: "CLI"` (uppercase) which fails API lookups since Sentry slugs are always lowercase. The other three parsing paths (`parseWithDash`, `parseAfterSlash`, `parseMultiSlashIssueArg`) were already fixed in PR #496. ## Fix Added `.toLowerCase()` to the project slug in `issueArgFromUrl` and updated two test expectations to match.
1 parent 9c198e9 commit a266720

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/lib/arg-parsing.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ function issueArgFromUrl(parsed: ParsedSentryUrl): ParsedIssueArg | null {
400400
const project = issueId.slice(0, dashIdx);
401401
const suffix = issueId.slice(dashIdx + 1).toUpperCase();
402402
if (project && suffix) {
403-
return { type: "explicit", org: parsed.org, project, suffix };
403+
// Lowercase project slug — Sentry slugs are always lowercase.
404+
return {
405+
type: "explicit",
406+
org: parsed.org,
407+
project: project.toLowerCase(),
408+
suffix,
409+
};
404410
}
405411
}
406412

test/lib/arg-parsing.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,26 +345,26 @@ describe("parseIssueArg", () => {
345345
});
346346
});
347347

348-
test("issue URL with short ID returns explicit", () => {
348+
test("issue URL with short ID returns explicit with lowercase project", () => {
349349
expect(
350350
parseIssueArg("https://sentry.io/organizations/my-org/issues/CLI-G/")
351351
).toEqual({
352352
type: "explicit",
353353
org: "my-org",
354-
project: "CLI",
354+
project: "cli",
355355
suffix: "G",
356356
});
357357
});
358358

359-
test("issue URL with multi-part short ID returns explicit", () => {
359+
test("issue URL with multi-part short ID returns explicit with lowercase project", () => {
360360
expect(
361361
parseIssueArg(
362362
"https://sentry.io/organizations/my-org/issues/SPOTLIGHT-ELECTRON-4Y/"
363363
)
364364
).toEqual({
365365
type: "explicit",
366366
org: "my-org",
367-
project: "SPOTLIGHT-ELECTRON",
367+
project: "spotlight-electron",
368368
suffix: "4Y",
369369
});
370370
});

0 commit comments

Comments
 (0)