n8n-io/n8n · error · NodeOperationError

A non-empty prompt is required.

Error message

A non-empty prompt is required.

What it means

Prompt guard in the shared baseAnalyze helper used by Gemini document/audio analysis. Reads the 'text' parameter; if it trims to empty, throws before building the generationConfig or calling the API. Same contract as the other Gemini prompt guards.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/helpers/baseAnalyze.ts:22

	type IExecuteFunctions,
	type INodeExecutionData,
} from 'n8n-workflow';

import type { Content, GenerateContentResponse } from './interfaces';
import { downloadFile, uploadFile } from './utils';
import { apiRequest } from '../transport';

export async function baseAnalyze(
	this: IExecuteFunctions,
	i: number,
	urlsPropertyName: string,
	fallbackMimeType: string,
): 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, {});
	validateNodeParameters(
		options,
		{ maxOutputTokens: { type: 'number', required: false } },
		this.getNode(),
	);
	const generationConfig = {
		maxOutputTokens: options.maxOutputTokens,
	};

	let contents: Content[];
	if (inputType === 'url') {
		const urls = this.getNodeParameter(urlsPropertyName, i, '') as string;
		const filesDataPromises = urls

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Provide a non-empty instruction in the 'text' field, or fix the expression (e.g. ($json.instruction ?? '').trim() || 'Summarize this').
  2. Ensure the upstream node emits the referenced field for every item.
  3. Filter out items lacking an instruction before this node.

Example fix

// before
const text = '';

// after
const text = 'Extract the key entities from this document.';
Defensive patterns

Strategy: validation

Validate before calling

const text = String(this.getNodeParameter('text', i, '')).trim();
if (!text) {
  throw new Error('Analyze requires a non-empty instruction text');
}

Type guard

function isNonEmptyInstruction(t: unknown): t is string {
  return typeof t === 'string' && t.trim().length > 0;
}

Prevention

When it happens

Trigger: The 'text' (prompt/instruction) field is empty or whitespace for the current item, or its expression resolved to undefined (e.g. $json.question where the upstream field is missing).

Common situations: Analyzing a document/audio but the instruction text wasn't filled; an expression pointed at the wrong field; a Set node upstream dropped the field.

Related errors


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