@@ -75,8 +75,6 @@ export function mapTextractSdkError(
7575 return new TextractRouteError ( `This document format is not supported.${ hint } ` , 400 )
7676 }
7777
78- // No status at all (e.g. a network failure before AWS responded) is a server-side problem, not a
79- // bad request — default to 500 so tool-execution retry logic still treats it as retryable.
8078 const status = err . $metadata ?. httpStatusCode ?? 500
8179 return new TextractRouteError ( err . message || 'Textract API error' , status )
8280}
@@ -91,6 +89,7 @@ export type ResolveDocumentResult =
9189 | { ok : true ; document : ResolvedDocument }
9290 | { ok : false ; response : NextResponse }
9391
92+ /** Passes through the document host's real HTTP status on failure, so tool-execution retry logic can still treat a transient 5xx as retryable. */
9493async function fetchDocumentBytes ( url : string ) : Promise < { bytes : Buffer ; contentType : string } > {
9594 const urlValidation = await validateUrlWithDNS ( url , 'Document URL' )
9695 if ( ! urlValidation . isValid ) {
@@ -102,8 +101,6 @@ async function fetchDocumentBytes(url: string): Promise<{ bytes: Buffer; content
102101 } )
103102 if ( ! response . ok ) {
104103 await response . text ( ) . catch ( ( ) => { } )
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.
107104 throw new TextractRouteError (
108105 `Failed to fetch document: ${ response . statusText } ` ,
109106 response . status
0 commit comments