n8n-io/n8n · error · NodeOperationError

User ID is not available. This node requires an…

Error message

User ID is not available. This node requires an authenticated user session.

What it means

Thrown by ensureUserId/getUserScopedSlot when the execution context has no authenticated user ID. The helper reads context.additionalData.userId and requires a non-empty string; if it is absent the user-scoped slot (collection/table/namespace name) cannot be derived. This guards user-scoped vector stores (e.g. AI memory).

Solutions

  1. Run the user-scoped memory node from an authenticated UI session so additionalData.userId is populated.
  2. If triggering via API/webhook, ensure the execution carries the owning user (check n8n user/owner execution settings).
  3. For non-interactive workloads, use a non-user-scoped vector store node instead.
  4. Confirm the n8n version propagates additionalData.userId to the execution context for your trigger type.

Example fix

// before: workflow triggered by anonymous webhook -> additionalData.userId undefined
// after:  run from an authenticated session, or switch to a non-user-scoped store node
Defensive patterns

Strategy: type-guard

Validate before calling

const ad = (context as any).additionalData; const userId = ad && typeof ad === 'object' && typeof ad.userId === 'string' ? ad.userId : undefined; if (!userId) { /* switch to non-user-scoped node, or abort with a clear message */ }

Type guard

function hasUserId(c: unknown): c is { additionalData: { userId: string } } { const ad = (c as any)?.additionalData; return !!ad && typeof ad.userId === 'string' && ad.userId.length > 0; }

Try / catch

try { const slot = getUserScopedSlot(context, prefix); } catch (e) { if (/User ID is not available/.test(e.message)) { /* use non-scoped fallback or stop */ } else throw e; }

Prevention

When it happens

Trigger: getUserScopedSlot or ensureUserId is called in a context where additionalData.userId is undefined or non-string — e.g. executing the workflow via API/trigger without a user session, running in a worker/process that does not propagate the user, or using a user-scoped memory node outside an authenticated UI session.

Common situations: Manual/test run without a logged-in owner; webhook/queue-triggered execution that does not carry a user; self-hosted setup where the user session is not forwarded to the executing process; using a user-scoped node in a context that n8n does not consider user-authenticated.

Understand the failure class

Related errors


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

Appendix: source

Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/shared/userScoped.ts:35

): string {
	const userId = ensureUserId(context, itemIndex);
	return `${prefix}_${userId}`.replace(/[^a-zA-Z0-9_]/g, '_');
}

export function ensureUserId(
	context: IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions,
	itemIndex?: number,
): string {
	const userId =
		'additionalData' in context &&
		typeof context.additionalData === 'object' &&
		context.additionalData !== null &&
		'userId' in context.additionalData
			? context.additionalData.userId
			: undefined;

	if (typeof userId !== 'string' || !userId) {
		throw new NodeOperationError(
			context.getNode(),
			'User ID is not available. This node requires an authenticated user session.',
			{ itemIndex },
		);
	}

	return userId;
}

View on GitHub (pinned to 5ac6606e81)