{"record":{"id":"0dd0c7278dca9e38","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required","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/actions/text/message.operation.ts","lineNumber":325,"sourceCode":"\tthrow new NodeOperationError(\n\t\tthis.getNode(),\n\t\t`Unsupported file type: ${mimeType}. Only images and PDFs are supported.`,\n\t);\n}\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;\n\tconst rawMessages = this.getNodeParameter('messages.values', i, []) as Message[];\n\tconst addAttachments = this.getNodeParameter('addAttachments', i, false) as boolean;\n\tconst simplify = this.getNodeParameter('simplify', i, true) as boolean;\n\tconst options = this.getNodeParameter('options', i, {}) as MessageOptions;\n\n\tconst messages = rawMessages.filter(\n\t\t(m) => typeof m.content !== 'string' || m.content.trim() !== '',\n\t);\n\n\tif (!addAttachments && messages.length === 0) {\n\t\tthrow new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {\n\t\t\titemIndex: i,\n\t\t});\n\t}\n\n\tconst { tools, connectedTools } = await getTools.call(this, options);\n\n\tif (addAttachments) {\n\t\tif (options.codeExecution) {\n\t\t\tawait addCodeAttachmentsToMessages.call(this, i, messages);\n\t\t} else {\n\t\t\tawait addRegularAttachmentsToMessages.call(this, i, messages);\n\t\t}\n\t}\n\n\tconst body = {\n\t\tmodel,\n\t\tmessages,\n\t\ttools,","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/actions/text/message.operation.ts#L307-L343","documentation":"Thrown by the Anthropic text/message operation when addAttachments is false AND all messages have been filtered out (messages.length === 0). Messages with empty or whitespace-only content are filtered out at line 320-322; if none remain and no attachments are being added, there is nothing to send to the API. This is a pre-flight validation check before any API call is made.","triggerScenarios":"The user configures a message with content that is empty or only whitespace (which gets filtered out), and 'Add Attachments' is not enabled. With zero messages and no attachments, the Anthropic Messages API would reject the request, so the node validates and throws early.","commonSituations":"Expression in the message content field evaluates to empty string for all items; message was configured but content field left blank; a preceding node produced empty output that feeds into the message content; user intended to use attachments but forgot to enable the 'Add Attachments' toggle.","solutions":["Enter non-empty content in at least one message in the Messages parameter, or use an expression that guarantees non-empty output.","If you intend to send only attachments (no text), enable the 'Add Attachments' toggle — the validation only fires when both messages are empty AND attachments are disabled.","Verify upstream nodes produce the expected non-empty data that feeds into the message content expressions.","Add a default/fallback value in the expression to avoid empty strings (e.g. {{ $json.content || 'Please analyze this.' }})."],"exampleFix":"// before — message content is empty or whitespace, Add Attachments is off\n// messages: [{ role: 'user', content: '   ' }]\n\n// after — provide non-empty content\n// messages: [{ role: 'user', content: 'Summarize this document.' }]\n// or enable 'Add Attachments' if sending files only","handlingStrategy":"validation","validationCode":"// In an upstream Code node, ensure at least one non-empty message:\nconst messages = items[0].json.messages || [];\nconst hasContent = messages.some(m => m.content && m.content.trim() !== '');\nconst hasAttachments = items[0].json.addAttachments === true;\nif (!hasContent && !hasAttachments) {\n  throw new Error('Anthropic text message requires either non-empty content or attachments enabled.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide at least one message with non-empty, non-whitespace content.","If sending attachments only, enable the 'Add Attachments' toggle to bypass the empty-message check.","Use expression fallbacks for message content (e.g. {{ $json.text || 'Default prompt' }}).","Validate input data in an upstream Code node to ensure prompt content is non-empty."],"tags":["validation","prompt","anthropic","empty-input"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}