{"record":{"id":"0d95992a5144a96d","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required-0d9599","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/analyze.operation.ts","lineNumber":139,"sourceCode":"\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['analyze'],\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\tlet model = 'gpt-4-vision-preview';\n\tif (this.getNode().typeVersion >= 1.4) {\n\t\tmodel = this.getNodeParameter('modelId', i, 'gpt-4o', { extractValue: true }) as string;\n\t}\n\n\tconst text = this.getNodeParameter('text', i, '') as string;\n\tif (!text.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 inputType = this.getNodeParameter('inputType', i) as string;\n\tconst options = this.getNodeParameter('options', i, {});\n\n\tconst content: IDataObject[] = [\n\t\t{\n\t\t\ttype: 'text',\n\t\t\ttext,\n\t\t},\n\t];\n\n\tconst detail = (options.detail as string) || 'auto';\n\n\tif (inputType === 'url') {\n\t\tconst imageUrls = (this.getNodeParameter('imageUrls', i) as string)\n\t\t\t.split(',')","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/image/analyze.operation.ts#L121-L157","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Enter a descriptive prompt in the 'text' field of the Analyze Image operation","If using an expression, add a fallback: {{$json[\"question\"] || 'Describe this image'}}, or use an IF/Switch node to skip empty prompts","Add a Set node before this operation to ensure the prompt is always non-empty"],"exampleFix":"// before — text: '' or text: '   '\n// after  — text: 'Describe the main objects in this image'","handlingStrategy":"validation","validationCode":"const text = this.getNodeParameter('text', i, '') as string;\nif (!text || !text.trim()) {\n  throw new UserError('A non-empty prompt is required for image analysis.');\n}","typeGuard":"function isNonEmptyPrompt(value: unknown): value is string {\n  return typeof value === 'string' && value.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always provide a descriptive prompt for image analysis","Use expressions with fallbacks: {{$json[\"question\"] || 'Describe this image'}},","Add an IF node to filter out items with empty prompts 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"}