Skip to content

Commit dd92247

Browse files
committed
fix(textract): pass through the real upstream status for filePath fetch failures
fetchDocumentBytes hardcoded 400 for any non-OK response from a document URL, masking transient 5xx failures from the document host as client errors and blocking tool-execution retries. Use the actual response status instead.
1 parent 790ef5a commit dd92247

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/sim/app/api/tools/textract/shared.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ async function fetchDocumentBytes(url: string): Promise<{ bytes: Buffer; content
102102
})
103103
if (!response.ok) {
104104
await response.text().catch(() => {})
105-
throw new TextractRouteError(`Failed to fetch document: ${response.statusText}`, 400)
105+
// Pass through the document host's real status (e.g. a transient 503) instead of a
106+
// hardcoded 400, so tool-execution retry logic can still treat 5xx as retryable.
107+
throw new TextractRouteError(
108+
`Failed to fetch document: ${response.statusText}`,
109+
response.status
110+
)
106111
}
107112

108113
const arrayBuffer = await response.arrayBuffer()

0 commit comments

Comments
 (0)