FlowiseAI/Flowise · error · Error
Failed to process binary file: ${error.message}
Error message
Failed to process binary file: ${error.message} What it means
Top-level catch in the S3File binary processor. Any exception thrown while instantiating a format-specific loader (PDFLoader, DocxLoader, LoadOfSheet, PowerpointLoader, CSVLoader), calling its load(), or building the metadata map is rethrown wrapped in this message. Like error 180 it preserves only `error.message`, losing the stack trace and class.
Source
Thrown at packages/components/nodes/documentloaders/S3File/S3File.ts:985
lastModified: fileInfo.lastModified,
etag: fileInfo.etag,
bucketName: fileInfo.bucketName,
totalPages: docs.length // Total number of pages/sheets in the file
}
return docs.map((doc, index) => ({
...doc,
metadata: {
...doc.metadata, // Keep original loader metadata (page numbers, etc.)
...s3Metadata, // Add S3 metadata
pageIndex: index // Add page/sheet index
}
}))
}
return []
} catch (error) {
throw new Error(`Failed to process binary file: ${error.message}`)
} finally {
// Clean up temporary file
if (tempFilePath && fsDefault.existsSync(tempFilePath)) {
try {
fsDefault.unlinkSync(tempFilePath)
} catch (e) {
console.warn(`Failed to delete temporary file: ${tempFilePath}`)
}
}
}
}
private async createTempFile(buffer: Buffer, fileName: string, mimeType: string): Promise<string> {
// Get appropriate file extension
let extension = path.extname(fileName)
if (!extension) {
const extensionMap: { [key: string]: string } = {
'application/pdf': '.pdf',View on GitHub (pinned to abe4a8601a)
Solutions
- Inspect `error.message` (it is propagated) and match it to the underlying loader's known failure modes.
- Download the S3 object locally and open it in the native app to confirm it is valid and unencrypted.
- Free disk space and verify the temp directory is writable.
- Update or pin the parsing library version known to handle the file.
- Add a pre-check (e.g. pdf-parse isEncrypted) before invoking the loader.
Example fix
// before
} catch (error) {
throw new Error(`Failed to process binary file: ${error.message}`)
}
// after
} catch (error: any) {
throw new Error(`Failed to process binary file (${fileInfo.mimeType}): ${error?.message ?? error}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'fs'
if (!fs.existsSync(tempFilePath)) {
throw new Error('Temp file missing before binary processing')
}
// crude magic-number check for PDF
const head = Buffer.alloc(4); const fd = fs.openSync(tempFilePath, 'r'); fs.readSync(fd, head, 0, 4, 0); fs.closeSync(fd)
if (fileInfo.mimeType === 'application/pdf' && head.toString() !== '%PDF') {
throw new Error('File claims to be PDF but is not')
} Type guard
function isIDocumentArray(v: unknown): v is { pageContent: string; metadata: Record<string, unknown> }[] {
return Array.isArray(v) && v.every(d => d && typeof (d as any).pageContent === 'string')
} Try / catch
try {
return await processBinaryFile(...)
} catch (e: any) {
// propagate but keep the inner message + cause
throw new Error(`Binary processing failed: ${e.message}`, { cause: e })
} Prevention
- Pre-validate file integrity (magic bytes) before parsing.
- Ensure temp directory has free disk space.
- Pin parsing library versions and run smoke tests on sample files.
- Surface the original error class to improve diagnosability.
When it happens
Trigger: A loader throws because the temp file is corrupt (e.g. truncated PDF), the spreadsheet has a locked structure, pdf-parse fails on an encrypted PDF, the CSV has invalid encoding, or fsDefault.existsSync/unlinkSync in finally throws before the catch completes.
Common situations: Corrupted uploads, password-protected Office/PDF docs, EML/HTML disguised with an Office MIME, disk-full during temp file write, or a version mismatch in the parsing library (pdf-parse, exceljs).
Related errors
- Failed to load file ${filePath} using unstructured loader.
- Unsupported binary file type: ${mimeType}
- Could not find JSON block in the output.
- Failed to parse a valid scenario from the LLM's response. Pl
- Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${excepti
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/bcf0a9b3ccfddd60.
Report an issue: GitHub.