{"record":{"id":"27eaeb27fb589955","repo":"FlowiseAI/Flowise","slug":"failed-to-load-file-filepath-using-unstructured","errorCode":null,"errorMessage":"Failed to load file ${filePath} using unstructured loader.","messagePattern":"Failed to load file (.+?) using unstructured loader\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/S3File/S3File.ts","lineNumber":817,"sourceCode":"                        ocrLanguages,\n                        xmlKeepTags,\n                        multiPageSections,\n                        combineUnderNChars,\n                        newAfterNChars,\n                        maxCharacters\n                    }\n\n                    if (unstructuredAPIKey) obj.apiKey = unstructuredAPIKey\n\n                    const unstructuredLoader = new UnstructuredLoader(filePath, obj)\n\n                    let docs = await handleDocumentLoaderDocuments(unstructuredLoader)\n\n                    docs = handleDocumentLoaderMetadata(docs, _omitMetadataKeys, metadata, sourceIdKey)\n\n                    return handleDocumentLoaderOutput(docs, output)\n                } catch {\n                    throw new Error(`Failed to load file ${filePath} using unstructured loader.`)\n                }\n            } finally {\n                fsDefault.rmSync(tempDir, { recursive: true, force: true })\n            }\n        }\n\n        return loader.load()\n    }\n\n    private getMimeTypeFromExtension(fileName: string): string {\n        const extension = path.extname(fileName).toLowerCase()\n        const mimeTypeMap: { [key: string]: string } = {\n            '.pdf': 'application/pdf',\n            '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n            '.doc': 'application/msword',\n            '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n            '.xls': 'application/vnd.ms-excel',\n            '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',","sourceCodeStart":799,"sourceCodeEnd":835,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/S3File/S3File.ts#L799-L835","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n} catch {\n    throw new Error(`Failed to load file ${filePath} using unstructured loader.`)\n}\n\n// after\n} catch (e: any) {\n    throw new Error(`Failed to load file ${filePath} using unstructured loader: ${e?.message ?? e}`)\n}","handlingStrategy":"try-catch","validationCode":"// Before calling the loader, verify the file exists and the API is reachable\nimport fs from 'fs'\nif (!fs.existsSync(filePath) || fs.statSync(filePath).size === 0) {\n    throw new Error(`Cannot load: temp file missing or empty at ${filePath}`)\n}\nconst url = new URL(unstructuredAPIUrl) // throws on malformed URL\n// optionally HEAD the endpoint\n","typeGuard":"function isUnstructuredConfig(v: unknown): v is { apiUrl: string; apiKey?: string } {\n    if (typeof v !== 'object' || v === null) return false\n    const o = v as any\n    return typeof o.apiUrl === 'string' && /^https?:\\/\\//.test(o.apiUrl)\n}","tryCatchPattern":"try {\n    return await handleDocumentLoaderOutput(docs, output)\n} catch (e: any) {\n    // preserve root cause for upstream handling\n    throw new Error(`Unstructured load failed for ${filePath}: ${e?.message ?? e}`, { cause: e })\n}","preventionTips":["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."],"tags":["s3","unstructured","document-loader","error-masking","network"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}