{"record":{"id":"4ec2ab425b4b9751","repo":"n8n-io/n8n","slug":"model-output-doesn-t-fit-required-format","errorCode":null,"errorMessage":"Model output doesn't fit required format","messagePattern":"Model output doesn't fit required format","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/InformationExtractor.node.ts","lineNumber":305,"sourceCode":"\t\t\t\tconst batch = items.slice(i, i + batchSize);\n\t\t\t\tconst batchPromises = batch.map(async (_item, batchItemIndex) => {\n\t\t\t\t\tconst itemIndex = i + batchItemIndex;\n\t\t\t\t\treturn await processItem(this, itemIndex, llm, parser);\n\t\t\t\t});\n\n\t\t\t\tconst batchResults = await Promise.allSettled(batchPromises);\n\n\t\t\t\tbatchResults.forEach((response, index) => {\n\t\t\t\t\tif (response.status === 'rejected') {\n\t\t\t\t\t\tconst error = wrapLangChainParserError(response.reason, this.getNode(), i + index);\n\t\t\t\t\t\tif (this.continueOnFail()) {\n\t\t\t\t\t\t\tresultData.push({\n\t\t\t\t\t\t\t\tjson: { error: error.message },\n\t\t\t\t\t\t\t\tpairedItem: { item: i + index },\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthrow new NodeOperationError(this.getNode(), error);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tconst output = response.value;\n\t\t\t\t\tresultData.push({ json: { output } });\n\t\t\t\t});\n\n\t\t\t\t// Add delay between batches if not the last batch\n\t\t\t\tif (i + batchSize < items.length && delayBetweenBatches > 0) {\n\t\t\t\t\tawait sleep(delayBetweenBatches);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Sequential processing\n\t\t\tfor (let itemIndex = 0; itemIndex < items.length; itemIndex++) {\n\t\t\t\ttry {\n\t\t\t\t\tconst output = await processItem(this, itemIndex, llm, parser);\n\t\t\t\t\tresultData.push({ json: { output } });\n\t\t\t\t} catch (error) {","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/InformationExtractor.node.ts#L287-L323","documentation":"Thrown by the Information Extractor when a Promise.allSettled batch promise rejected and continueOnFail is false. The rejection reason is wrapped via wrapLangChainParserError first; the wrapped error becomes a NodeOperationError. It typically means the LLM output could not be parsed into the required structured schema even after the OutputFixingParser retry.","triggerScenarios":"For an item in the batch, the LLM returned text that the StructuredOutputParser (wrapped in OutputFixingParser) could not coerce into the Zod/JSON schema. allSettled marks the promise rejected, and since continueOnFail is off, the NodeOperationError propagates.","commonSituations":"The LLM is weak/instructed poorly and returns free text instead of JSON; the schema is too strict or ambiguous; the model does not support structured output well; temperature is too high causing erratic output; the system prompt template was customized poorly.","solutions":["Enable 'Continue On Fail' on the node so rejected items return an error JSON instead of aborting the whole run.","Reduce the schema complexity or make fields optional so the parser can succeed more often.","Use a stronger / instruction-tuned model that follows JSON schema reliably.","Improve the system prompt template to clearly specify the required output format.","Lower the model temperature to reduce output variability."],"exampleFix":"// before — aborts the whole run on first rejection\nif (response.status === 'rejected') {\n  const error = wrapLangChainParserError(response.reason, this.getNode(), i + index);\n  if (this.continueOnFail()) {\n    resultData.push({ json: { error: error.message }, pairedItem: { item: i + index } });\n    return;\n  } else {\n    throw new NodeOperationError(this.getNode(), error);\n  }\n}\n\n// after — default to per-item error so one bad item does not kill the batch\nif (response.status === 'rejected') {\n  const error = wrapLangChainParserError(response.reason, this.getNode(), i + index);\n  resultData.push({ json: { error: error.message, raw: String(response.reason) }, pairedItem: { item: i + index } });\n  if (!this.continueOnFail()) {\n    throw new NodeOperationError(this.getNode(), error);\n  }\n  return;\n}","handlingStrategy":"fallback","validationCode":"// Pre-flight: confirm schema is non-trivial and model is connected\nif (!llm) throw new Error('Connect a chat model');\nif (schemaType === 'fromAttributes' && attributes.length === 0) {\n  throw new Error('Add attributes before running extraction');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await parser.parse(llmOutput);\n} catch (e) {\n  // Enable continueOnFail so the item gets an error JSON instead of aborting the batch\n  resultData.push({ json: { error: (e as Error).message }, pairedItem: { item: i + index } });\n}","preventionTips":["Enable Continue On Fail to isolate failing items in a batch.","Simplify the schema and make non-critical fields optional.","Use a strong instruction-tuned model and lower temperature.","Keep the default system prompt template unless you fully understand the format requirements."],"tags":["llm-output","parsing","schema","information-extractor","batch"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}