n8n-io/n8n · error · NodeOperationError

A non-empty prompt is required.

Error message

A non-empty prompt is required.

What it means

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.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/Anthropic/helpers/baseAnalyze.ts:17

import { NodeOperationError, type IExecuteFunctions, type INodeExecutionData } from 'n8n-workflow';

import type { Content, MessagesResponse } from './interfaces';
import { getBaseUrl, splitByComma } from './utils';
import { apiRequest } from '../transport';

export async function baseAnalyze(
	this: IExecuteFunctions,
	i: number,
	urlsPropertyName: string,
	type: 'image' | 'document',
): Promise<INodeExecutionData[]> {
	const model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;
	const inputType = this.getNodeParameter('inputType', i, 'url') as string;
	const text = this.getNodeParameter('text', i, '') as string;
	if (!text.trim()) {
		throw new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {
			itemIndex: i,
		});
	}
	const simplify = this.getNodeParameter('simplify', i, true) as boolean;
	const options = this.getNodeParameter('options', i, {});
	const baseUrl = await getBaseUrl.call(this);
	const fileUrlPrefix = `${baseUrl}/v1/files/`;

	let content: Content[];
	if (inputType === 'url') {
		const urls = this.getNodeParameter(urlsPropertyName, i, '') as string;
		content = splitByComma(urls).map((url) => {
			if (url.startsWith(fileUrlPrefix)) {
				return {
					type,
					source: {
						type: 'file',
						file_id: url.replace(fileUrlPrefix, ''),

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Enter a non-empty text prompt in the 'text' parameter field (e.g. 'Describe this image' or 'Extract all key information from this document').
  2. If using an expression, ensure it always produces non-empty output (e.g. {{ $json.prompt || 'Analyze this.' }}).
  3. Verify upstream nodes produce the expected prompt text.

Example fix

// before — text parameter is empty
// text: ''

// after — provide a non-empty prompt
// text: 'Describe the key elements in this image.'
Defensive patterns

Strategy: validation

Validate before calling

// In an upstream Code node, validate the text prompt:
const text = items[0].json.text || '';
if (!text.trim()) {
  throw new Error('Analysis text prompt is required and cannot be empty.');
}
// or set a default:
items[0].json.text = text.trim() || 'Analyze this content.';

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/87179f282a85cae5. Report an issue: GitHub.