n8n-io/n8n · error · NodeOperationError

The 'prompt' parameter is empty.

Error message

The 'prompt' parameter is empty.

What it means

Thrown by processItem in the Basic LLM Chain when the resolved 'prompt' value is undefined. For typeVersion <= 1.3 the prompt is read directly from the 'prompt' parameter; for newer versions it is resolved through getPromptInputByType. If either yields undefined, the chain has nothing to send to the LLM.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/processItem.ts:65

	const outputParser = await getOptionalOutputParser(ctx, itemIndex);

	// Get user prompt based on node version
	let prompt: string;

	if (ctx.getNode().typeVersion <= 1.3) {
		prompt = ctx.getNodeParameter('prompt', itemIndex) as string;
	} else {
		prompt = getPromptInputByType({
			ctx,
			i: itemIndex,
			inputKey: 'text',
			promptTypeKey: 'promptType',
		});
	}

	// Validate prompt
	if (prompt === undefined) {
		throw new NodeOperationError(ctx.getNode(), "The 'prompt' parameter is empty.");
	}

	// Get chat messages if configured
	const messages = ctx.getNodeParameter(
		'messages.messageValues',
		itemIndex,
		[],
	) as MessageTemplate[];

	// Execute the chain
	return await executeChain({
		context: ctx,
		itemIndex,
		query: prompt,
		llm,
		outputParser,
		messages,
		fallbackLlm,

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Open the Basic LLM Chain and verify the prompt parameter/expression resolves to a non-empty string for every input item.
  2. Use a fallback in the expression, e.g. {{$json.prompt || 'Summarize the following:'}}.
  3. Inspect the failing itemIndex in the execution data to see which field is missing.
  4. If using promptType other than 'text', confirm the prompt source value is provided.

Example fix

// before
if (prompt === undefined) {
  throw new NodeOperationError(ctx.getNode(), "The 'prompt' parameter is empty.");
}

// after — also reject empty strings and surface itemIndex
if (!prompt?.trim()) {
  throw new NodeOperationError(ctx.getNode(), {
    message: "The 'prompt' parameter is empty.",
    itemIndex,
  });
}
Defensive patterns

Strategy: validation

Validate before calling

let prompt: string;
if (ctx.getNode().typeVersion <= 1.3) {
  prompt = ctx.getNodeParameter('prompt', itemIndex) as string;
} else {
  prompt = getPromptInputByType({ ctx, i: itemIndex, inputKey: 'text', promptTypeKey: 'promptType' });
}
if (!prompt?.trim()) {
  throw new Error(`Prompt is empty for item ${itemIndex}`);
}

Type guard

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

Prevention

When it happens

Trigger: The prompt parameter (or the expression backing the 'text' prompt input) evaluates to undefined for the current itemIndex. Common with expression-based prompts that reference a missing JSON field.

Common situations: The prompt expression references {{$json.field}} but field does not exist on the input item; the user left the prompt field blank; the prompt source was switched (e.g. from 'text' to 'definition') but no value supplied; upstream node changed its output shape.

Related errors


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