n8n-io/n8n · error · NodeOperationError

Text for item ${itemIndex} is not defined

Error message

Text for item ${itemIndex} is not defined

What it means

Thrown by Information Extractor processItem when the 'text' parameter for the current item is missing or whitespace-only. The node trims the input and refuses empty text because there is nothing for the LLM to extract attributes from.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/chains/InformationExtractor/processItem.ts:21

import { ChatPromptTemplate, SystemMessagePromptTemplate } from '@langchain/core/prompts';
import type { OutputFixingParser } from '@langchain/classic/output_parsers';
import { NodeOperationError, type IExecuteFunctions } from 'n8n-workflow';

import { wrapLangChainParserError } from '@utils/output_parsers/langchainParserError';
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,
	llm: BaseLanguageModel,
	parser: OutputFixingParser<object>,
) {
	const input = ctx.getNodeParameter('text', itemIndex) as string;
	if (!input?.trim()) {
		throw new NodeOperationError(ctx.getNode(), `Text for item ${itemIndex} is not defined`, {
			itemIndex,
		});
	}
	const inputPrompt = new HumanMessage(input);

	const options = ctx.getNodeParameter('options', itemIndex, {}) as {
		systemPromptTemplate?: string;
	};

	const escapedTemplate = (options.systemPromptTemplate ?? SYSTEM_PROMPT_TEMPLATE).replace(
		/[{}]/g,
		(match) => match + match,
	);

	const systemPromptTemplate = SystemMessagePromptTemplate.fromTemplate(
		`${escapedTemplate}
{format_instructions}`,
	);

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Filter items with empty text upstream using an If node on the text field.
  2. Fix the expression so it resolves to the correct non-empty source field.
  3. Default to a placeholder if empty: {{$json.text || 'N/A'}}.
  4. Enable Continue On Fail so empty items are skipped with an error JSON rather than aborting.

Example fix

// before
const input = ctx.getNodeParameter('text', itemIndex) as string;
if (!input?.trim()) {
  throw new NodeOperationError(ctx.getNode(), `Text for item ${itemIndex} is not defined`, { itemIndex });
}

// after — same guard, but include a hint about the source field
if (!input?.trim()) {
  throw new NodeOperationError(ctx.getNode(), {
    message: `Text for item ${itemIndex} is empty. Provide non-empty input text for extraction.`,
    itemIndex,
  });
}
Defensive patterns

Strategy: validation

Validate before calling

const input = ctx.getNodeParameter('text', itemIndex, '') as string;
if (!input.trim()) {
  throw new Error(`Item ${itemIndex} has empty text; nothing to extract`);
}

Type guard

function isNonEmptyString(v: unknown): v is string {
  return typeof v === 'string' && v.trim().length > 0;
}

Prevention

When it happens

Trigger: The 'text' parameter (or its expression) resolves to an empty or whitespace-only string for itemIndex. The guard !input?.trim() catches both undefined and blank.

Common situations: Input items where the source text field is empty (e.g. an empty email body, a blank row from a spreadsheet); the expression references a missing key; upstream filtering did not remove empty-text items.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/72456be224d95745. Report an issue: GitHub.