n8n-io/n8n · error · NodeOperationError
A non-empty prompt is required.
Error message
A non-empty prompt is required.
What it means
The Generate Image operation requires a non-empty prompt. After reading the 'prompt' parameter, the code checks prompt.trim(). If the prompt is blank or whitespace-only, it throws a NodeOperationError before calling the OpenAI image generation API. This prevents sending an empty generation request.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/image/generate.operation.ts:259
},
],
},
];
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('model', i) 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 options = this.getNodeParameter('options', i, {});
let response_format = 'b64_json';
let binaryPropertyOutput = 'data';
if (options.returnImageUrls) {
response_format = 'url';
}
if (options.binaryPropertyOutput) {
binaryPropertyOutput = options.binaryPropertyOutput as string;
delete options.binaryPropertyOutput;
}
if (options.dalleQuality) {
options.quality = options.dalleQuality;View on GitHub (pinned to 5ac6606e81)
Solutions
- Enter a descriptive prompt for image generation
- If using an expression, add a fallback: {{$json["description"] || 'A serene landscape'}}, or use an IF node to filter empty prompts
- Validate upstream data has the prompt field populated before this node
Example fix
// before — prompt: '' // after — prompt: 'A futuristic city skyline at sunset, digital art style'
Defensive patterns
Strategy: validation
Validate before calling
const prompt = this.getNodeParameter('prompt', i) as string;
if (!prompt || !prompt.trim()) {
throw new UserError('A non-empty prompt is required for image generation.');
} Type guard
function isNonEmptyPrompt(value: unknown): value is string {
return typeof value === 'string' && value.trim().length > 0;
} Prevention
- Always enter a descriptive prompt for image generation
- Use expressions with fallbacks: {{$json["description"] || 'A scenic landscape'}},
- Filter items with empty prompts using an IF node before this operation
When it happens
Trigger: The 'prompt' parameter in the Generate Image operation is empty, contains only whitespace, or resolves to empty via an expression. The trim() check catches whitespace-only values.
Common situations: Prompt field left empty; expression like {{$json["description"]}} resolves to empty from upstream data; user expects a default prompt but none is configured.
Related errors
- A non-empty prompt is required.
- A non-empty prompt is required.
- A non-empty prompt is required.
- A non-empty prompt is required.
- A non-empty prompt is required.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/11863e6cc7190fa2.
Report an issue: GitHub.