From 5eefc3c2b22f670b5657ac0a3d8bc96896a9ce0f Mon Sep 17 00:00:00 2001 From: Gaurav Chadha Date: Thu, 27 Nov 2025 14:59:07 +0530 Subject: [PATCH] stringify-error Signed-off-by: Gaurav Chadha --- apps/api/src/controllers/v1/extract-status.ts | 8 +++++++- apps/api/src/controllers/v2/extract-status.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/api/src/controllers/v1/extract-status.ts b/apps/api/src/controllers/v1/extract-status.ts index 4a61cdc7a..c232d0f1c 100644 --- a/apps/api/src/controllers/v1/extract-status.ts +++ b/apps/api/src/controllers/v1/extract-status.ts @@ -116,7 +116,13 @@ export async function extractStatusController( success: status === "failed" ? false : true, data, status, - error: typeof extract?.error === "string" ? extract.error : undefined, + error: (() => { + if (typeof extract?.error === "string") return extract.error; + if (extract?.error && typeof extract.error === "object") { + return extract.error.message || extract.error.error || JSON.stringify(extract.error); + } + return undefined; + })(), expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(), steps: extract?.showSteps ? extract.steps : undefined, llmUsage: extract?.showLLMUsage ? extract.llmUsage : undefined, diff --git a/apps/api/src/controllers/v2/extract-status.ts b/apps/api/src/controllers/v2/extract-status.ts index f640a14b0..f68081d54 100644 --- a/apps/api/src/controllers/v2/extract-status.ts +++ b/apps/api/src/controllers/v2/extract-status.ts @@ -116,7 +116,13 @@ export async function extractStatusController( success: status === "failed" ? false : true, data, status, - error: typeof extract?.error === "string" ? extract.error : undefined, + error: (() => { + if (typeof extract?.error === "string") return extract.error; + if (extract?.error && typeof extract.error === "object") { + return extract.error.message || extract.error.error || JSON.stringify(extract.error); + } + return undefined; + })(), expiresAt: (await getExtractExpiry(req.params.jobId)).toISOString(), steps: extract?.showSteps ? extract.steps : undefined, llmUsage: extract?.showLLMUsage ? extract.llmUsage : undefined,