{"record":{"id":"87179f282a85cae5","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required-87179f","errorCode":null,"errorMessage":"A non-empty prompt is required.","messagePattern":"A non-empty prompt is required\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/helpers/baseAnalyze.ts","lineNumber":17,"sourceCode":"import { NodeOperationError, type IExecuteFunctions, type INodeExecutionData } from 'n8n-workflow';\n\nimport type { Content, MessagesResponse } from './interfaces';\nimport { getBaseUrl, splitByComma } from './utils';\nimport { apiRequest } from '../transport';\n\nexport async function baseAnalyze(\n\tthis: IExecuteFunctions,\n\ti: number,\n\turlsPropertyName: string,\n\ttype: 'image' | 'document',\n): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;\n\tconst inputType = this.getNodeParameter('inputType', i, 'url') as string;\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 simplify = this.getNodeParameter('simplify', i, true) as boolean;\n\tconst options = this.getNodeParameter('options', i, {});\n\tconst baseUrl = await getBaseUrl.call(this);\n\tconst fileUrlPrefix = `${baseUrl}/v1/files/`;\n\n\tlet content: Content[];\n\tif (inputType === 'url') {\n\t\tconst urls = this.getNodeParameter(urlsPropertyName, i, '') as string;\n\t\tcontent = splitByComma(urls).map((url) => {\n\t\t\tif (url.startsWith(fileUrlPrefix)) {\n\t\t\t\treturn {\n\t\t\t\t\ttype,\n\t\t\t\t\tsource: {\n\t\t\t\t\t\ttype: 'file',\n\t\t\t\t\t\tfile_id: url.replace(fileUrlPrefix, ''),","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/helpers/baseAnalyze.ts#L1-L35","documentation":"Thrown by baseAnalyze (shared by Anthropic image and document analysis operations) when the 'text' parameter (the analysis prompt/instruction) is empty or whitespace-only after trimming. Unlike the message operation, this check does not depend on attachments — a non-empty text prompt is always required for analysis operations. The check runs before any content is assembled or API call is made.","triggerScenarios":"The 'text' parameter (the analysis prompt) is empty, contains only whitespace, or an expression evaluating to it resolves to an empty string. This applies to both image analysis and document analysis operations that use baseAnalyze. The error fires before URL or binary input processing.","commonSituations":"Prompt field left blank in the node UI; expression in the text field evaluates to empty string for some input items; upstream node produced an empty value that feeds into the text expression; user assumed the image/document alone was sufficient without a text instruction.","solutions":["Enter a non-empty text prompt in the 'text' parameter field (e.g. 'Describe this image' or 'Extract all key information from this document').","If using an expression, ensure it always produces non-empty output (e.g. {{ $json.prompt || 'Analyze this.' }}).","Verify upstream nodes produce the expected prompt text."],"exampleFix":"// before — text parameter is empty\n// text: ''\n\n// after — provide a non-empty prompt\n// text: 'Describe the key elements in this image.'","handlingStrategy":"validation","validationCode":"// In an upstream Code node, validate the text prompt:\nconst text = items[0].json.text || '';\nif (!text.trim()) {\n  throw new Error('Analysis text prompt is required and cannot be empty.');\n}\n// or set a default:\nitems[0].json.text = text.trim() || 'Analyze this content.';","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always enter a descriptive analysis instruction in the text parameter.","Use expression fallbacks to guarantee non-empty text (e.g. {{ $json.instruction || 'Describe this image.' }}).","Validate that upstream nodes produce non-empty prompt text before the Anthropic analysis node."],"tags":["validation","prompt","anthropic","empty-input","analyze"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}