{"record":{"id":"dd9121cf99f9f071","repo":"FlowiseAI/Flowise","slug":"failed-to-partition-file-with-error-response-sta","errorCode":null,"errorMessage":"Failed to partition file with error ${response.status} and message ${await response.text()}","messagePattern":"Failed to partition file with error (.+?) and message (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/documentloaders/Unstructured/Unstructured.ts","lineNumber":139,"sourceCode":"        if (this.newAfterNChars !== undefined) {\n            formData.append('new_after_n_chars', String(this.newAfterNChars))\n        }\n        if (this.maxCharacters !== undefined) {\n            formData.append('max_characters', String(this.maxCharacters))\n        }\n\n        const headers = {\n            'UNSTRUCTURED-API-KEY': this.apiKey || ''\n        }\n\n        const response = await fetch(this.apiUrl, {\n            method: 'POST',\n            body: formData,\n            headers\n        })\n\n        if (!response.ok) {\n            throw new Error(`Failed to partition file with error ${response.status} and message ${await response.text()}`)\n        }\n\n        const elements = await response.json()\n        if (!Array.isArray(elements)) {\n            throw new Error(`Expected partitioning request to return an array, but got ${elements}`)\n        }\n        return elements.filter((el) => typeof el.text === 'string') as Element[]\n    }\n\n    async loadAndSplitBuffer(buffer: Buffer, fileName: string): Promise<Document[]> {\n        const elements = await this._partition(buffer, fileName)\n\n        const documents: Document[] = []\n        for (const element of elements) {\n            const { metadata, text } = element\n            if (typeof text === 'string') {\n                documents.push(\n                    new Document({","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/documentloaders/Unstructured/Unstructured.ts#L121-L157","documentation":"UnstructuredLoader._partition posts multipart form data to the Unstructured API and rejects when fetch resolves with a non-ok status. The message embeds the HTTP status and the raw response body text returned by the partition endpoint.","triggerScenarios":"Unstructured API returns 4xx/5xx: missing/invalid UNSTRUCTURED-API-KEY (401/403), malformed multipart body (422), file type the server cannot partition (422), or server-side failure (500/502/503).","commonSituations":"Self-hosted Unstructured pointing at a wrong apiUrl, expired API key, file format unsupported by the deployed Unstructured version, oversized payload beyond reverse-proxy limits (413), or service downtime.","solutions":["Read the embedded status and body text — they name the exact upstream problem.","Verify apiUrl points to a reachable Unstructured endpoint and the UNSTRUCTURED-API-KEY header is valid.","For 413/422: shrink or convert the file; check reverse-proxy client_max_body_size.","For 5xx: retry with backoff; confirm the Unstructured service health.","Pin a compatible Unstructured API version if the schema changed."],"exampleFix":"// before\nif (!response.ok) {\n    throw new Error(`Failed to partition file with error ${response.status} and message ${await response.text()}`)\n}\n\n// after\nif (!response.ok) {\n    const body = await response.text()\n    const err = new Error(`Failed to partition file (${fileName}): status ${response.status}, body: ${body}`)\n    ;(err as any).status = response.status\n    throw err\n}","handlingStrategy":"retry","validationCode":"try { new URL(unstructuredAPIUrl) } catch { throw new Error('Invalid Unstructured API URL') }\nif (!unstructuredAPIKey && requiresAuth) throw new Error('Unstructured API key required for this endpoint')","typeGuard":"function isUnstructuredOk(r: Response): boolean { return r.ok }","tryCatchPattern":"for (let attempt = 0; attempt < 3; attempt++) {\n    const res = await fetch(apiUrl, { method: 'POST', body: formData, headers })\n    if (res.ok) return await res.json()\n    if ([429, 500, 502, 503, 504].includes(res.status) && attempt < 2) {\n        await sleep(2 ** attempt * 500); continue\n    }\n    throw new Error(`Partition failed (${res.status}): ${await res.text()}`)\n}","preventionTips":["Verify the Unstructured endpoint and key at node init.","Retry 429/5xx with exponential backoff; surface 4xx immediately.","Shrink large files or raise reverse-proxy body limits to avoid 413.","Pin a compatible Unstructured API version."],"tags":["unstructured","api","http-status","document-loader"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}