{"record":{"id":"11863e6cc7190fa2","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required-11863e","errorCode":null,"errorMessage":"A non-empty prompt is required.","messagePattern":"A non-empty prompt is required\\.","errorType":"validation","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/image/generate.operation.ts","lineNumber":259,"sourceCode":"\t\t\t},\n\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['generate'],\n\t\tresource: ['image'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('model', i) as string;\n\tconst prompt = this.getNodeParameter('prompt', i) as string;\n\tif (!prompt.trim()) {\n\t\tthrow new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {\n\t\t\titemIndex: i,\n\t\t});\n\t}\n\tconst options = this.getNodeParameter('options', i, {});\n\tlet response_format = 'b64_json';\n\tlet binaryPropertyOutput = 'data';\n\n\tif (options.returnImageUrls) {\n\t\tresponse_format = 'url';\n\t}\n\n\tif (options.binaryPropertyOutput) {\n\t\tbinaryPropertyOutput = options.binaryPropertyOutput as string;\n\t\tdelete options.binaryPropertyOutput;\n\t}\n\n\tif (options.dalleQuality) {\n\t\toptions.quality = options.dalleQuality;","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/image/generate.operation.ts#L241-L277","documentation":"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.","triggerScenarios":"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.","commonSituations":"Prompt field left empty; expression like {{$json[\"description\"]}} resolves to empty from upstream data; user expects a default prompt but none is configured.","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"],"exampleFix":"// before — prompt: ''\n// after  — prompt: 'A futuristic city skyline at sunset, digital art style'","handlingStrategy":"validation","validationCode":"const prompt = this.getNodeParameter('prompt', i) as string;\nif (!prompt || !prompt.trim()) {\n  throw new UserError('A non-empty prompt is required for image generation.');\n}","typeGuard":"function isNonEmptyPrompt(value: unknown): value is string {\n  return typeof value === 'string' && value.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["openai","image","prompt","validation","empty-input","v1"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}