FlowiseAI/Flowise · error · Error

Failed to partition file with error ${response.status} and m

Error message

Failed to partition file with error ${response.status} and message ${await response.text()}

What it means

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.

Source

Thrown at packages/components/nodes/documentloaders/Unstructured/Unstructured.ts:139

        if (this.newAfterNChars !== undefined) {
            formData.append('new_after_n_chars', String(this.newAfterNChars))
        }
        if (this.maxCharacters !== undefined) {
            formData.append('max_characters', String(this.maxCharacters))
        }

        const headers = {
            'UNSTRUCTURED-API-KEY': this.apiKey || ''
        }

        const response = await fetch(this.apiUrl, {
            method: 'POST',
            body: formData,
            headers
        })

        if (!response.ok) {
            throw new Error(`Failed to partition file with error ${response.status} and message ${await response.text()}`)
        }

        const elements = await response.json()
        if (!Array.isArray(elements)) {
            throw new Error(`Expected partitioning request to return an array, but got ${elements}`)
        }
        return elements.filter((el) => typeof el.text === 'string') as Element[]
    }

    async loadAndSplitBuffer(buffer: Buffer, fileName: string): Promise<Document[]> {
        const elements = await this._partition(buffer, fileName)

        const documents: Document[] = []
        for (const element of elements) {
            const { metadata, text } = element
            if (typeof text === 'string') {
                documents.push(
                    new Document({

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Read the embedded status and body text — they name the exact upstream problem.
  2. Verify apiUrl points to a reachable Unstructured endpoint and the UNSTRUCTURED-API-KEY header is valid.
  3. For 413/422: shrink or convert the file; check reverse-proxy client_max_body_size.
  4. For 5xx: retry with backoff; confirm the Unstructured service health.
  5. Pin a compatible Unstructured API version if the schema changed.

Example fix

// before
if (!response.ok) {
    throw new Error(`Failed to partition file with error ${response.status} and message ${await response.text()}`)
}

// after
if (!response.ok) {
    const body = await response.text()
    const err = new Error(`Failed to partition file (${fileName}): status ${response.status}, body: ${body}`)
    ;(err as any).status = response.status
    throw err
}
Defensive patterns

Strategy: retry

Validate before calling

try { new URL(unstructuredAPIUrl) } catch { throw new Error('Invalid Unstructured API URL') }
if (!unstructuredAPIKey && requiresAuth) throw new Error('Unstructured API key required for this endpoint')

Type guard

function isUnstructuredOk(r: Response): boolean { return r.ok }

Try / catch

for (let attempt = 0; attempt < 3; attempt++) {
    const res = await fetch(apiUrl, { method: 'POST', body: formData, headers })
    if (res.ok) return await res.json()
    if ([429, 500, 502, 503, 504].includes(res.status) && attempt < 2) {
        await sleep(2 ** attempt * 500); continue
    }
    throw new Error(`Partition failed (${res.status}): ${await res.text()}`)
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


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