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 edit operation when the 'prompt' parameter is empty or contains only whitespace. The check validates that prompt is a string and that its trimmed value is non-empty before proceeding to model selection, image upload, and the API call. A non-empty edit instruction is required because the Gemini image editing model needs a text description of the desired edit.

Source

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

				hint: 'The name of the output field to put the binary file data in',
			},
		],
	},
];

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

export const description = updateDisplayOptions(displayOptions, properties);

export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
	const prompt = this.getNodeParameter('prompt', i, '');
	if (typeof prompt === 'string' && !prompt.trim()) {
		throw new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {
			itemIndex: i,
		});
	}
	let model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;
	if (!model) {
		model = 'models/gemini-2.5-flash-image-preview';
	}

	const binaryPropertyOutput = this.getNodeParameter('options.binaryPropertyOutput', i, 'edited');
	const outputKey = typeof binaryPropertyOutput === 'string' ? binaryPropertyOutput : 'data';

	// Collect image binary field names from collection
	const imagesParam = this.getNodeParameter('images', i, {
		values: [{ binaryPropertyName: 'data' }],
	});

	if (!isImagesParameter(imagesParam)) {
		throw new Error('Invalid images parameter format');

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Enter a non-empty edit instruction in the Prompt field (e.g. 'Remove the background and replace it with a beach scene').
  2. If using an expression, add a fallback (e.g. {{ $json.instruction || 'Edit this image.' }}).
  3. Verify upstream nodes produce non-empty prompt text for all items.

Example fix

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

// after — describe the desired edit
// prompt: 'Add a sunset background behind the subject'
Defensive patterns

Strategy: validation

Validate before calling

// In an upstream Code node, validate the edit prompt:
const prompt = items[0].json.prompt || '';
if (typeof prompt !== 'string' || !prompt.trim()) {
  throw new Error('Image edit prompt is required and cannot be empty.');
}

Prevention

When it happens

Trigger: The 'prompt' parameter in the image edit operation is empty, whitespace-only, or an expression that evaluates to an empty string. The check fires at the top of execute() before any image data is read or uploaded.

Common situations: Prompt field left blank; expression evaluating the prompt resolves to empty for some input items; user uploaded images but forgot to describe the edit they want; upstream node produced empty data feeding the prompt expression.

Related errors


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