Skip to content

Commit 6a60754

Browse files
authored
fix: include API endpoint in error messages for better diagnostics (CLI-BS) (#500)
## Problem The generic `API request failed: 404 Not Found` from `apiRequest()` doesn't identify which endpoint failed. This affects **24 users** ([CLI-BS](https://sentry.sentry.io/issues/7316293255/)) across issue view, whoami, and log list commands. ## Fix Two changes: 1. **Pass endpoint to ApiError** in `apiRequest()` so it's captured in telemetry 2. **Show endpoint in `ApiError.format()`** so users see which API path failed: ``` API request failed: 404 Not Found Endpoint: /auth/ {"detail": "Not found."} ``` This helps users identify: - Self-hosted endpoints that don't exist (e.g., `/auth/` on older instances) - Wrong org/project context causing resource-not-found - Missing features (e.g., logs endpoint not enabled)
1 parent 8236325 commit 6a60754

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/lib/api/infrastructure.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ export async function apiRequestToRegion<T>(
296296
throw new ApiError(
297297
`API request failed: ${response.status} ${response.statusText}`,
298298
response.status,
299-
detail
299+
detail,
300+
endpoint
300301
);
301302
}
302303

src/lib/errors.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export class ApiError extends CliError {
6161

6262
override format(): string {
6363
let msg = this.message;
64+
if (this.endpoint) {
65+
msg += `\n Endpoint: ${this.endpoint}`;
66+
}
6467
if (this.detail && this.detail !== this.message) {
6568
msg += `\n ${this.detail}`;
6669
}

0 commit comments

Comments
 (0)