Skip to content

Commit d171428

Browse files
authored
fix(event): correctly parse project/event-id in view command (#1263)
This PR fixes an issue where `sentry event view <project>/<event-id>` would fail with a `ContextError: Event ID is required.` The root cause was that `parseSingleArg` in `src/commands/event/view.ts` was incorrectly delegating single-slash arguments like `project/event-id` to `parseSlashSeparatedArg`. The `parseSlashSeparatedArg` function, when encountering a single slash, assumes the format is `org/project` and that an event ID is missing, leading it to throw the `ContextError`. The fix adds a specific check within `parseSingleArg` for the `project/event-id` pattern (where the part after the slash is a valid hex event ID) before the delegation to `parseSlashSeparatedArg`. This ensures that such arguments are correctly parsed and handled, preventing the erroneous `ContextError`. Fixes [CLI-CG](https://sentry.sentry.io/issues/7322504022/?seerDrawer=true) <sub>Comment `@sentry <feedback>` on this PR to have Autofix iterate on the changes.</sub> Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
1 parent 0341d1e commit d171428

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/commands/event/view.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,17 @@ function parseSingleArg(arg: string): ParsedPositionalArgs {
228228
issueShortId: beforeSlash,
229229
};
230230
}
231+
232+
// "project/EVENT-ID" → project slug + hex event ID.
233+
// e.g., "my-project/abc123def456abc123def456abc123de"
234+
// Must be checked before parseSlashSeparatedArg, which throws ContextError
235+
// for any single-slash arg, assuming it's "org/project" with a missing ID.
236+
if (afterSlash && HEX_ID_RE.test(normalizeHexId(afterSlash))) {
237+
return {
238+
eventId: normalizeHexId(afterSlash),
239+
targetArg: beforeSlash,
240+
};
241+
}
231242
}
232243

233244
const { id: eventId, targetArg } = parseSlashSeparatedArg(

0 commit comments

Comments
 (0)