{"record":{"id":"1d22e933878f7f1e","repo":"n8n-io/n8n","slug":"text-to-classify-for-item-itemindex-is-not-defi","errorCode":null,"errorMessage":"Text to classify for item ${itemIndex} is not defined","messagePattern":"Text to classify for item (.+?) is not defined","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/chains/TextClassifier/processItem.ts","lineNumber":26,"sourceCode":"import { toParserInputText } from '@utils/output_parsers/parserInput';\nimport { getTracingConfig } from '@utils/tracing';\n\nimport { SYSTEM_PROMPT_TEMPLATE } from './constants';\n\nexport async function processItem(\n\tctx: IExecuteFunctions,\n\titemIndex: number,\n\titem: INodeExecutionData,\n\tllm: BaseLanguageModel,\n\tparser: StructuredOutputParser<any> | OutputFixingParser<any>,\n\tcategories: Array<{ category: string; description: string }>,\n\tmultiClassPrompt: string,\n\tfallbackPrompt: string | undefined,\n): Promise<Record<string, unknown>> {\n\tconst input = ctx.getNodeParameter('inputText', itemIndex) as string;\n\n\tif (!input) {\n\t\tthrow new NodeOperationError(\n\t\t\tctx.getNode(),\n\t\t\t`Text to classify for item ${itemIndex} is not defined`,\n\t\t);\n\t}\n\n\titem.pairedItem = { item: itemIndex };\n\n\tconst inputPrompt = new HumanMessage(input);\n\n\tconst systemPromptTemplateOpt = ctx.getNodeParameter(\n\t\t'options.systemPromptTemplate',\n\t\titemIndex,\n\t\tSYSTEM_PROMPT_TEMPLATE,\n\t) as string;\n\tconst escapedTemplate = (systemPromptTemplateOpt ?? SYSTEM_PROMPT_TEMPLATE)\n\t\t.replace(/[{}]/g, (match) => match + match)\n\t\t.replaceAll('{{categories}}', '{categories}');\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/chains/TextClassifier/processItem.ts#L8-L44","documentation":"Thrown by Text Classifier processItem when the 'inputText' parameter for the current item is falsy (undefined, null, empty string, or 0). The classifier needs text content to classify, so a missing value halts the per-item call.","triggerScenarios":"The inputText expression resolves to a falsy value for itemIndex. The guard triggers before the LLM is invoked.","commonSituations":"The inputText field references a missing JSON key; the source text field is empty for some items; upstream node changed output schema; the user left the field blank.","solutions":["Set inputText to an expression that resolves to a non-empty string for every item.","Filter items with empty text upstream using an If node.","Provide a fallback in the expression: {{$json.text || 'No content'}}.","Enable Continue On Fail so empty items return an error JSON."],"exampleFix":"// before\nconst input = ctx.getNodeParameter('inputText', itemIndex) as string;\nif (!input) {\n  throw new NodeOperationError(ctx.getNode(), `Text to classify for item ${itemIndex} is not defined`);\n}\n\n// after — reject only whitespace, include itemIndex in metadata\nconst input = ctx.getNodeParameter('inputText', itemIndex, '') as string;\nif (!input.trim()) {\n  throw new NodeOperationError(ctx.getNode(), {\n    message: `Text to classify for item ${itemIndex} is not defined`,\n    itemIndex,\n  });\n}","handlingStrategy":"validation","validationCode":"const input = ctx.getNodeParameter('inputText', itemIndex, '') as string;\nif (!input.trim()) {\n  throw new Error(`Item ${itemIndex} has empty text; nothing to classify`);\n}","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Filter items with empty text upstream.","Provide a fallback in the inputText expression.","Enable Continue On Fail to skip empty items gracefully."],"tags":["configuration","parameter-validation","text-classifier","per-item"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}