FlowiseAI/Flowise · error · Error
Failed to download file ${keyName} from S3 bucket ${bucketNa
Error message
Failed to download file ${keyName} from S3 bucket ${bucketName}: ${e.message} What it means
Thrown inside S3File's loader.load override when downloading a single object fails. Wraps the underlying error (network, NoSuchKey, access denied, stream error, 'Response body is not a readable stream') and interpolates its message, naming both keyName and bucketName for diagnosis.
Source
Thrown at packages/components/nodes/documentloaders/S3File/S3File.ts:786
const response = await s3Client.send(getObjectCommand)
const objectData = await new Promise<Buffer>((resolve, reject) => {
const chunks: Buffer[] = []
if (response.Body instanceof Readable) {
response.Body.on('data', (chunk: Buffer) => chunks.push(chunk))
response.Body.on('end', () => resolve(Buffer.concat(chunks)))
response.Body.on('error', reject)
} else {
reject(new Error('Response body is not a readable stream.'))
}
})
fsDefault.mkdirSync(path.dirname(filePath), { recursive: true })
fsDefault.writeFileSync(filePath, objectData)
} catch (e: any) {
throw new Error(`Failed to download file ${keyName} from S3 bucket ${bucketName}: ${e.message}`)
}
try {
const obj: UnstructuredLoaderOptions = {
apiUrl: unstructuredAPIUrl,
strategy,
encoding,
coordinates,
skipInferTableTypes,
hiResModelName,
includePageBreaks,
chunkingStrategy,
ocrLanguages,
xmlKeepTags,
multiPageSections,
combineUnderNChars,
newAfterNChars,
maxCharactersView on GitHub (pinned to abe4a8601a)
Solutions
- Confirm the keyName exists in the bucket (aws s3 ls s3://bucket/keyName).
- Verify IAM s3:GetObject permission and that the bucket region matches s3Config.
- Check disk space and tempDir writability for writeFileSync.
- Ensure the Readable stream check matches your AWS SDK v3 runtime (Node Readable vs web ReadableStream).
- Re-throw with { cause: e } to preserve the original stack.
Example fix
// before
} catch (e: any) {
throw new Error(`Failed to download file ${keyName} from S3 bucket ${bucketName}: ${e.message}`)
}
// after
} catch (e: any) {
const reason = e instanceof Error ? e.message : String(e)
throw new Error(`Failed to download file ${keyName} from S3 bucket ${bucketName}: ${reason}`, { cause: e })
} Defensive patterns
Strategy: validation
Validate before calling
async function verifyObjectAccessible(s3Client, bucket, key) {
await s3Client.send(new (require('@aws-sdk/client-s3').HeadObjectCommand)({ Bucket: bucket, Key: key }))
} Type guard
const { Readable } = require('stream')
function isReadable(body) { return body instanceof Readable } Try / catch
try {
return await s3FileLoader.load()
} catch (e) {
if (/Failed to download file .* from S3 bucket/.test(e.message)) {
throw new Error('S3 object download failed — check key, IAM, and region', { cause: e })
}
throw e
} Prevention
- Run a HeadObject pre-check to confirm the key exists and is readable.
- Ensure IAM s3:GetObject and correct region in s3Config.
- Confirm tempDir writability and disk space.
- Match the SDK v3 Body stream type to the Readable check.
When it happens
Trigger: GetObjectCommand returns NoSuchKey (wrong/typo key); AccessDenied (IAM lacks s3:GetObject); stream 'error' event fires mid-download; response.Body is not a Readable stream (SDK v3 shape/version mismatch); fsDefault.writeFileSync fails (disk full / path permission).
Common situations: Key name typo or wrong folder prefix; bucket in a different region than s3Config; IAM role not granted read; very large file stream timeout; AWS SDK v3 version where Body is a ReadableStream (web) not a Node Readable.
Related errors
- Failed to download file ${key} from S3 bucket ${bucketName}:
- Failed to load data from bucket ${bucketName}: ${e.message}
- Failed to load S3 document: ${error.message}
- Failed to load file ${filePath} using unstructured loader.
- Unsupported binary file type: ${mimeType}
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/ca44c6f2b71eabdd.
Report an issue: GitHub.