FlowiseAI/Flowise · error · Error
Failed to load file ${filePath} using unstructured loader.
Error message
Failed to load file ${filePath} using unstructured loader. What it means
Thrown when the S3File document loader cannot parse a downloaded S3 object via the Unstructured API. The try block wraps UnstructuredLoader construction, document fetching, metadata handling, and output shaping; any failure inside it is swallowed and rethrown as this generic message. Because the original error is discarded by a bare `catch {}`, the real cause (bad API key, network timeout, unsupported file content, malformed partition response) is invisible to the caller.
Source
Thrown at packages/components/nodes/documentloaders/S3File/S3File.ts:817
ocrLanguages,
xmlKeepTags,
multiPageSections,
combineUnderNChars,
newAfterNChars,
maxCharacters
}
if (unstructuredAPIKey) obj.apiKey = unstructuredAPIKey
const unstructuredLoader = new UnstructuredLoader(filePath, obj)
let docs = await handleDocumentLoaderDocuments(unstructuredLoader)
docs = handleDocumentLoaderMetadata(docs, _omitMetadataKeys, metadata, sourceIdKey)
return handleDocumentLoaderOutput(docs, output)
} catch {
throw new Error(`Failed to load file ${filePath} using unstructured loader.`)
}
} finally {
fsDefault.rmSync(tempDir, { recursive: true, force: true })
}
}
return loader.load()
}
private getMimeTypeFromExtension(fileName: string): string {
const extension = path.extname(fileName).toLowerCase()
const mimeTypeMap: { [key: string]: string } = {
'.pdf': 'application/pdf',
'.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'.doc': 'application/msword',
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'.xls': 'application/vnd.ms-excel',
'.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',View on GitHub (pinned to abe4a8601a)
Solutions
- Check the Unstructured API URL and key in the node inputs and verify the endpoint is reachable with a curl POST.
- Temporarily replace the bare `catch {}` with `catch (e) { throw new Error('...: ' + e.message) }` to surface the root cause, then revert.
- Verify the downloaded temp file at filePath is non-empty and openable before calling the loader.
- Confirm the file type is supported by your Unstructured version and that the file is not password-protected.
- Increase request timeouts or retry with backoff if the failure is intermittent.
Example fix
// before
} catch {
throw new Error(`Failed to load file ${filePath} using unstructured loader.`)
}
// after
} catch (e: any) {
throw new Error(`Failed to load file ${filePath} using unstructured loader: ${e?.message ?? e}`)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before calling the loader, verify the file exists and the API is reachable
import fs from 'fs'
if (!fs.existsSync(filePath) || fs.statSync(filePath).size === 0) {
throw new Error(`Cannot load: temp file missing or empty at ${filePath}`)
}
const url = new URL(unstructuredAPIUrl) // throws on malformed URL
// optionally HEAD the endpoint
Type guard
function isUnstructuredConfig(v: unknown): v is { apiUrl: string; apiKey?: string } {
if (typeof v !== 'object' || v === null) return false
const o = v as any
return typeof o.apiUrl === 'string' && /^https?:\/\//.test(o.apiUrl)
} Try / catch
try {
return await handleDocumentLoaderOutput(docs, output)
} catch (e: any) {
// preserve root cause for upstream handling
throw new Error(`Unstructured load failed for ${filePath}: ${e?.message ?? e}`, { cause: e })
} Prevention
- Validate the Unstructured API URL and key in node init before downloading.
- Surface the underlying error instead of swallowing it in a bare catch.
- Pre-check the temp file is non-empty before invoking the loader.
- Add a health-check call to the Unstructured endpoint at startup.
When it happens
Trigger: Initiating an S3File load with the Unstructured loader path selected (unstructuredAPIUrl configured), where the downloaded file fails to partition. This happens when the Unstructured API URL is unreachable/wrong, the API key is missing or rejected, the file content is corrupt or password-protected, the temp file write at filePath fails, or the partition response is non-array.
Common situations: Misconfigured UNSTRUCTURED_API_URL pointing to a deleted/local instance, expired or empty unstructuredAPIKey, very large files exceeding the API timeout, transient network blips to the Unstructured service, or a file extension that the mime map accepts but Unstructured itself cannot partition.
Related errors
- Failed to process binary file: ${error.message}
- Failed to fetch ${url}: ${error}
- Failed to load S3 document: ${error.message}
- Unsupported binary file type: ${mimeType}
- Failed to partition file with error ${response.status} and m
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/27eaeb27fb589955.
Report an issue: GitHub.