n8n-io/n8n · error · NodeOperationError

A non-empty prompt is required.

Error message

A non-empty prompt is required.

What it means

Thrown by the GoogleGemini image generate operation when the 'prompt' parameter is empty or whitespace-only after trimming. This is a pre-flight validation check at the top of execute() before model selection and API call. The Gemini image generation model requires a text prompt describing the desired image.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/image/generate.operation.ts:81

			},
		],
	},
];

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

export const description = updateDisplayOptions(displayOptions, properties);

export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
	const model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;
	const prompt = this.getNodeParameter('prompt', i, '') as string;
	if (!prompt.trim()) {
		throw new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {
			itemIndex: i,
		});
	}
	const binaryPropertyOutput = this.getNodeParameter(
		'options.binaryPropertyOutput',
		i,
		'data',
	) as string;

	if (model.includes('gemini')) {
		const generationConfig = {
			responseModalities: [Modality.IMAGE, Modality.TEXT],
		};
		const body: GenerateContentRequest = {
			contents: [
				{
					role: 'user',
					parts: [{ text: prompt }],

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Enter a non-empty text description of the desired image in the Prompt field (e.g. 'A serene mountain landscape at sunset with a lake in the foreground').
  2. If using an expression, add a fallback value (e.g. {{ $json.description || 'A colorful abstract painting' }}).
  3. Verify upstream nodes produce non-empty prompt text for all items.

Example fix

// before — prompt is empty
// prompt: ''

// after — provide a descriptive prompt
// prompt: 'A futuristic city skyline at dusk with flying vehicles'
Defensive patterns

Strategy: validation

Validate before calling

// In an upstream Code node, validate the generation prompt:
const prompt = items[0].json.prompt || '';
if (!prompt.trim()) {
  throw new Error('Image generation prompt is required and cannot be empty.');
}
// or provide a default:
items[0].json.prompt = prompt.trim() || 'A beautiful abstract artwork.';

Prevention

When it happens

Trigger: The 'prompt' parameter is empty, contains only whitespace, or an expression evaluating to it produces an empty string. The check fires before the model is read and before any API call, so no API quota is consumed.

Common situations: Prompt field left blank in the node UI; expression in the prompt field evaluates to empty for some input items; upstream node produced empty data; user expected a default prompt but none is built into the node.

Related errors


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