n8n-io/n8n · error · NodeOperationError

A non-empty prompt is required.

Error message

A non-empty prompt is required.

What it means

The Analyze Image operation requires a non-empty text prompt. After reading the 'text' parameter, the code checks that text.trim() is non-empty. If the prompt is blank or contains only whitespace, it throws a NodeOperationError before any API call. This prevents wasting an API call on a prompt-less vision request.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/image/analyze.operation.ts:139

const displayOptions = {
	show: {
		operation: ['analyze'],
		resource: ['image'],
	},
};

export const description = updateDisplayOptions(displayOptions, properties);

export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
	let model = 'gpt-4-vision-preview';
	if (this.getNode().typeVersion >= 1.4) {
		model = this.getNodeParameter('modelId', i, 'gpt-4o', { extractValue: true }) as string;
	}

	const text = this.getNodeParameter('text', i, '') as string;
	if (!text.trim()) {
		throw new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {
			itemIndex: i,
		});
	}
	const inputType = this.getNodeParameter('inputType', i) as string;
	const options = this.getNodeParameter('options', i, {});

	const content: IDataObject[] = [
		{
			type: 'text',
			text,
		},
	];

	const detail = (options.detail as string) || 'auto';

	if (inputType === 'url') {
		const imageUrls = (this.getNodeParameter('imageUrls', i) as string)
			.split(',')

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Enter a descriptive prompt in the 'text' field of the Analyze Image operation
  2. If using an expression, add a fallback: {{$json["question"] || 'Describe this image'}}, or use an IF/Switch node to skip empty prompts
  3. Add a Set node before this operation to ensure the prompt is always non-empty

Example fix

// before — text: '' or text: '   '
// after  — text: 'Describe the main objects in this image'
Defensive patterns

Strategy: validation

Validate before calling

const text = this.getNodeParameter('text', i, '') as string;
if (!text || !text.trim()) {
  throw new UserError('A non-empty prompt is required for image analysis.');
}

Type guard

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

Prevention

When it happens

Trigger: The 'text' (prompt) parameter in the Analyze Image operation is empty, contains only spaces/whitespace, or was left at its default empty value. The trim() check catches whitespace-only inputs.

Common situations: User forgot to enter a prompt; the text parameter is populated from an upstream node that returned an empty string; an expression like {{$json["question"]}} resolves to empty.

Related errors


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