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,
                        maxCharacters

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Confirm the keyName exists in the bucket (aws s3 ls s3://bucket/keyName).
  2. Verify IAM s3:GetObject permission and that the bucket region matches s3Config.
  3. Check disk space and tempDir writability for writeFileSync.
  4. Ensure the Readable stream check matches your AWS SDK v3 runtime (Node Readable vs web ReadableStream).
  5. 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

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


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/ca44c6f2b71eabdd. Report an issue: GitHub.