n8n-io/n8n · error · NodeOperationError
Text to classify for item
Error message
Text to classify for item ${itemIndex} is not defined What it means
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.
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.
Example fix
// before
const input = ctx.getNodeParameter('inputText', itemIndex) as string;
if (!input) {
throw new NodeOperationError(ctx.getNode(), `Text to classify for item ${itemIndex} is not defined`);
}
// after — reject only whitespace, include itemIndex in metadata
const input = ctx.getNodeParameter('inputText', itemIndex, '') as string;
if (!input.trim()) {
throw new NodeOperationError(ctx.getNode(), {
message: `Text to classify for item ${itemIndex} is not defined`,
itemIndex,
});
} Defensive patterns
Strategy: validation
Validate before calling
const input = ctx.getNodeParameter('inputText', itemIndex, '') as string;
if (!input.trim()) {
throw new Error(`Item ${itemIndex} has empty text; nothing to classify`);
} Type guard
function isNonEmptyString(v: unknown): v is string {
return typeof v === 'string' && v.trim().length > 0;
} Prevention
- Filter items with empty text upstream.
- Provide a fallback in the inputText expression.
- Enable Continue On Fail to skip empty items gracefully.
When it happens
Trigger: The inputText expression resolves to a falsy value for itemIndex. The guard triggers before the LLM is invoked.
Common situations: 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.
Related errors
- At least one category must be defined
- No binary data set.
- Text for item is not defined
- The 'prompt' parameter is empty.
- The ‘query‘ parameter is empty.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/1d22e933878f7f1e.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/nodes-langchain/nodes/chains/TextClassifier/processItem.ts:26
import { toParserInputText } from '@utils/output_parsers/parserInput';
import { getTracingConfig } from '@utils/tracing';
import { SYSTEM_PROMPT_TEMPLATE } from './constants';
export async function processItem(
ctx: IExecuteFunctions,
itemIndex: number,
item: INodeExecutionData,
llm: BaseLanguageModel,
parser: StructuredOutputParser<any> | OutputFixingParser<any>,
categories: Array<{ category: string; description: string }>,
multiClassPrompt: string,
fallbackPrompt: string | undefined,
): Promise<Record<string, unknown>> {
const input = ctx.getNodeParameter('inputText', itemIndex) as string;
if (!input) {
throw new NodeOperationError(
ctx.getNode(),
`Text to classify for item ${itemIndex} is not defined`,
);
}
item.pairedItem = { item: itemIndex };
const inputPrompt = new HumanMessage(input);
const systemPromptTemplateOpt = ctx.getNodeParameter(
'options.systemPromptTemplate',
itemIndex,
SYSTEM_PROMPT_TEMPLATE,
) as string;
const escapedTemplate = (systemPromptTemplateOpt ?? SYSTEM_PROMPT_TEMPLATE)
.replace(/[{}]/g, (match) => match + match)
.replaceAll('{{categories}}', '{categories}');
View on GitHub (pinned to 5ac6606e81)