From e6d42d91cd9b462d917ffd281c184e3d8284007c Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Mon, 2 Feb 2026 18:33:55 -0600 Subject: [PATCH] Fix [object Object] error when API returns structured error detail The backend returns detail as an object for some errors (circular dependency, conflicts, etc.). The API client now JSON.stringifies object details so they can be properly parsed by error handlers like DependencyGraph. --- frontend/src/api.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 6404c97..9d1bd01 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -78,7 +78,13 @@ export class ForbiddenError extends ApiError { async function handleResponse(response: Response): Promise { if (!response.ok) { const error = await response.json().catch(() => ({ detail: 'Unknown error' })); - const message = error.detail || `HTTP ${response.status}`; + // Handle detail as string or object (backend may return structured errors) + let message: string; + if (typeof error.detail === 'object') { + message = JSON.stringify(error.detail); + } else { + message = error.detail || `HTTP ${response.status}`; + } if (response.status === 401) { throw new UnauthorizedError(message);