n8n-io/n8n · error · NodeOperationError
A non-empty prompt is required.
Error message
A non-empty prompt is required.
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/actions/text/message.operation.ts:325
throw new NodeOperationError(
this.getNode(),
`Unsupported file type: ${mimeType}. Only images and PDFs are supported.`,
);
}
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
const model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;
const rawMessages = this.getNodeParameter('messages.values', i, []) as Message[];
const addAttachments = this.getNodeParameter('addAttachments', i, false) as boolean;
const simplify = this.getNodeParameter('simplify', i, true) as boolean;
const options = this.getNodeParameter('options', i, {}) as MessageOptions;
const messages = rawMessages.filter(
(m) => typeof m.content !== 'string' || m.content.trim() !== '',
);
if (!addAttachments && messages.length === 0) {
throw new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {
itemIndex: i,
});
}
const { tools, connectedTools } = await getTools.call(this, options);
if (addAttachments) {
if (options.codeExecution) {
await addCodeAttachmentsToMessages.call(this, i, messages);
} else {
await addRegularAttachmentsToMessages.call(this, i, messages);
}
}
const body = {
model,
messages,
tools,View on GitHub (pinned to 5ac6606e81)
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.' }}).
Example fix
// before — message content is empty or whitespace, Add Attachments is off
// messages: [{ role: 'user', content: ' ' }]
// after — provide non-empty content
// messages: [{ role: 'user', content: 'Summarize this document.' }]
// or enable 'Add Attachments' if sending files only Defensive patterns
Strategy: validation
Validate before calling
// In an upstream Code node, ensure at least one non-empty message:
const messages = items[0].json.messages || [];
const hasContent = messages.some(m => m.content && m.content.trim() !== '');
const hasAttachments = items[0].json.addAttachments === true;
if (!hasContent && !hasAttachments) {
throw new Error('Anthropic text message requires either non-empty content or attachments enabled.');
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
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/0dd0c7278dca9e38.
Report an issue: GitHub.