n8n-io/n8n · error · NodeOperationError

The ‘text‘ parameter is empty.

Error message

The ‘text‘ parameter is empty.

What it means

Thrown by the OpenAI Assistant node when the per-item 'text' parameter (read via getNodeParameter('text', itemIndex)) resolves to undefined. The node needs a non-empty text string to send as the user message to the OpenAI Assistant thread, so an undefined value halts execution before the API call. The message text references 'text' because that is the node parameter name in the UI.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/agents/OpenAiAssistant/OpenAiAssistant.node.ts:346

		const items = this.getInputData();
		const returnData: INodeExecutionData[] = [];

		for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
			try {
				const input = this.getNodeParameter('text', itemIndex) as string;
				const assistantId = this.getNodeParameter('assistantId', itemIndex, '') as string;
				const nativeTools = this.getNodeParameter('nativeTools', itemIndex, []) as Array<
					'code_interpreter' | 'retrieval'
				>;

				const options = this.getNodeParameter('options', itemIndex, {}) as {
					baseURL?: string;
					maxRetries: number;
					timeout: number;
				};

				if (input === undefined) {
					throw new NodeOperationError(this.getNode(), 'The ‘text‘ parameter is empty.');
				}

				const { openAiDefaultHeaders } = Container.get(AiConfig);
				const defaultHeaders = mergeCustomHeaders(credentials, openAiDefaultHeaders ?? {});

				if (options.baseURL) {
					assertCredentialAllowsUrl({
						node: this.getNode(),
						credentialData: credentials,
						url: options.baseURL,
						pinnedUrl: typeof credentials.url === 'string' ? credentials.url : undefined,
						surface: 'OpenAI',
					});
				}

				const client = new OpenAIClient({
					apiKey: credentials.apiKey as string,
					maxRetries: options.maxRetries ?? 2,

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Open the OpenAiAssistant node and check the 'text' parameter expression; ensure the referenced field exists on the input items (use {{$json.fieldName}} only when fieldName is present).
  2. Add a guard in the expression, e.g. {{$json.text || 'No text provided'}} or use the isEmpty/Coalesce node upstream to guarantee a value.
  3. Inspect the input data of the failing item (the error's itemIndex) in the execution view to confirm which key is missing.
  4. If some items legitimately have no text, use the If/Switch node to filter them out before this node.

Example fix

// before
const input = this.getNodeParameter('text', itemIndex) as string;
if (input === undefined) {
  throw new NodeOperationError(this.getNode(), 'The text parameter is empty.');
}

// after — treat empty as a per-item skip rather than a hard failure
const input = this.getNodeParameter('text', itemIndex, '') as string;
if (!input?.trim()) {
  if (this.continueOnFail()) {
    returnData.push({ json: { error: 'No text provided' }, pairedItem: { item: itemIndex } });
    continue;
  }
  throw new NodeOperationError(this.getNode(), 'The text parameter is empty.', { itemIndex });
}
Defensive patterns

Strategy: validation

Validate before calling

// Before wiring the OpenAiAssistant node, validate each input item has text
const items = $('Predecessor').all();
const missing = items.filter((_, i) => !($('Predecessor').item.json.text ?? '').trim());
if (missing.length) {
  throw new Error(`${missing.length} items lack the 'text' field required by the OpenAiAssistant node`);
}

Type guard

function hasTextInput(item: { json: Record<string, unknown> }): boolean {
  return typeof item.json.text === 'string' && item.json.text.trim().length > 0;
}

Try / catch

try {
  // expression on text parameter that may resolve undefined
} catch (e) {
  // Provide a default or route to an error branch via Continue On Fail
}

Prevention

When it happens

Trigger: The 'text' parameter of the OpenAiAssistant node is empty or set to an expression that evaluates to undefined for the current item (e.g. {{$json.missingField}} where the field does not exist on the input item). Occurs per-item inside the execute loop, so it can fire on item 3 of 10 even if earlier items had valid text.

Common situations: The input field referenced by the text expression was renamed upstream, an item in the input array is missing the expected key, the user left the text parameter blank, or an upstream node emitted an item with an empty/null JSON value that the expression dereferences.

Related errors


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