Skip to content

Commit 3bcd5de

Browse files
authored
fix: enrich short ID 404 with org context and suggestions (CLI-A1) (#494)
## Problem When resolving an issue by short ID (e.g., `sentry issue view CLI-BM`) fails with 404, the error shows: ``` ApiError: Failed to resolve short ID: 404 Not Found ``` This doesn't tell the user what short ID was searched, which organization was searched, or what to do next. Affects **27 users** ([CLI-A1](https://sentry.sentry.io/issues/7297901204/)). ## Fix Enhanced the 404 error in `getIssueByShortId` to include context and suggestions: ``` Short ID 'CLI-BM' not found in organization 'sentry'. The issue may have been deleted or merged Verify the short ID and org: sentry issue view sentry/CLI-BM List issues in this org: sentry issue list sentry/ ``` ## Design Decisions - **Keeps ApiError type**: The enhanced error still has `status=404`, so `tryGetIssueByShortId` (used for parallel fan-out across orgs) continues to work unchanged — it catches `ApiError` by status code - **Inline detail**: Suggestions are formatted as the ApiError `detail` field, which `ApiError.format()` renders on indented lines below the main message - **Context-aware**: Includes the actual short ID and org slug so users can verify both
1 parent 0714d27 commit 3bcd5de

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/lib/api/issues.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,27 @@ export async function getIssueByShortId(
237237
},
238238
});
239239

240-
const data = unwrapResult(result, "Failed to resolve short ID");
240+
let data: ReturnType<typeof unwrapResult>;
241+
try {
242+
data = unwrapResult(result, "Failed to resolve short ID");
243+
} catch (error) {
244+
// Enrich 404 errors with actionable context. The generic
245+
// "Failed to resolve short ID: 404 Not Found" is the most common
246+
// issue view error (CLI-A1, 27 users). Callers like
247+
// tryGetIssueByShortId still catch ApiError by status code.
248+
if (error instanceof ApiError && error.status === 404) {
249+
throw new ApiError(
250+
`Short ID '${normalizedShortId}' not found in organization '${orgSlug}'`,
251+
404,
252+
[
253+
"The issue may have been deleted or merged",
254+
`Verify the short ID and org: sentry issue view ${orgSlug}/${normalizedShortId}`,
255+
`List issues in this org: sentry issue list ${orgSlug}/`,
256+
].join("\n ")
257+
);
258+
}
259+
throw error;
260+
}
241261

242262
// resolveAShortId returns a ShortIdLookupResponse with a group (issue)
243263
const resolved = data as unknown as { group?: SentryIssue };

0 commit comments

Comments
 (0)