Skip to content

Commit 1bbbc06

Browse files
committed
fix: capture normalized eventId and update E2E tests for hex validation
Use the return value of validateHexId() so UUID-format event IDs get normalized (dashes stripped) before downstream API calls. Update E2E tests to use valid 32-char hex IDs and add a dedicated test for invalid event ID format rejection.
1 parent 9783130 commit 1bbbc06

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/commands/event/view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ export const viewCommand = buildCommand({
737737
const log = logger.withTag("event.view");
738738

739739
// Parse positional args
740-
const { eventId, targetArg, warning, issueId, issueShortId } =
740+
let { eventId, targetArg, warning, issueId, issueShortId } =
741741
parsePositionalArgs(args);
742742
if (warning) {
743743
log.warn(warning);
@@ -746,8 +746,9 @@ export const viewCommand = buildCommand({
746746
// Validate event ID format early (before API calls) when the ID came
747747
// from user input. Skip when the ID is a sentinel from issue URL/short
748748
// ID detection — those paths resolve the event through issue lookup.
749+
// Capture the normalized return value (lowercased, UUID dashes stripped).
749750
if (eventId !== LATEST_EVENT_SENTINEL && !issueId && !issueShortId) {
750-
validateHexId(eventId, "event ID");
751+
eventId = validateHexId(eventId, "event ID");
751752
}
752753

753754
const parsed = parseOrgProjectArg(targetArg);

test/e2e/event.test.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe("sentry event view", () => {
5252
"event",
5353
"view",
5454
`${TEST_ORG}/${TEST_PROJECT}`,
55-
"abc123",
55+
"abc123def456abc123def456abc123de",
5656
]);
5757

5858
expect(result.exitCode).toBe(1);
@@ -62,12 +62,27 @@ describe("sentry event view", () => {
6262
test("requires org and project without DSN", async () => {
6363
await ctx.setAuthToken(TEST_TOKEN);
6464

65-
const result = await ctx.run(["event", "view", "abc123"]);
65+
const result = await ctx.run([
66+
"event",
67+
"view",
68+
"abc123def456abc123def456abc123de",
69+
]);
6670

6771
expect(result.exitCode).toBe(1);
6872
expect(result.stderr + result.stdout).toMatch(/organization|project/i);
6973
});
7074

75+
test("rejects invalid event ID format", async () => {
76+
await ctx.setAuthToken(TEST_TOKEN);
77+
78+
const result = await ctx.run(["event", "view", "abc123"]);
79+
80+
expect(result.exitCode).toBe(1);
81+
expect(result.stderr + result.stdout).toMatch(
82+
/invalid event id|32-character hexadecimal/i
83+
);
84+
});
85+
7186
test("handles non-existent event", async () => {
7287
await ctx.setAuthToken(TEST_TOKEN);
7388

@@ -76,7 +91,7 @@ describe("sentry event view", () => {
7691
"event",
7792
"view",
7893
`${TEST_ORG}/${TEST_PROJECT}`,
79-
"nonexistent123",
94+
"abc123def456abc123def456abc123de",
8095
]);
8196

8297
expect(result.exitCode).toBe(1);

0 commit comments

Comments
 (0)