{"record":{"id":"d20a6e3830430525","repo":"n8n-io/n8n","slug":"user-id-is-not-available-this-node-requires-an-au","errorCode":null,"errorMessage":"User ID is not available. This node requires an authenticated user session.","messagePattern":"User ID is not available\\. This node requires an authenticated user session\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/shared/userScoped.ts","lineNumber":35,"sourceCode":"): string {\n\tconst userId = ensureUserId(context, itemIndex);\n\treturn `${prefix}_${userId}`.replace(/[^a-zA-Z0-9_]/g, '_');\n}\n\nexport function ensureUserId(\n\tcontext: IExecuteFunctions | ISupplyDataFunctions | ILoadOptionsFunctions,\n\titemIndex?: number,\n): string {\n\tconst userId =\n\t\t'additionalData' in context &&\n\t\ttypeof context.additionalData === 'object' &&\n\t\tcontext.additionalData !== null &&\n\t\t'userId' in context.additionalData\n\t\t\t? context.additionalData.userId\n\t\t\t: undefined;\n\n\tif (typeof userId !== 'string' || !userId) {\n\t\tthrow new NodeOperationError(\n\t\t\tcontext.getNode(),\n\t\t\t'User ID is not available. This node requires an authenticated user session.',\n\t\t\t{ itemIndex },\n\t\t);\n\t}\n\n\treturn userId;\n}\n","sourceCodeStart":17,"sourceCodeEnd":44,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/shared/userScoped.ts#L17-L44","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the user-scoped memory node from an authenticated UI session so additionalData.userId is populated.","If triggering via API/webhook, ensure the execution carries the owning user (check n8n user/owner execution settings).","For non-interactive workloads, use a non-user-scoped vector store node instead.","Confirm the n8n version propagates additionalData.userId to the execution context for your trigger type."],"exampleFix":"// before: workflow triggered by anonymous webhook -> additionalData.userId undefined\n// after:  run from an authenticated session, or switch to a non-user-scoped store node","handlingStrategy":"type-guard","validationCode":"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 */ }","typeGuard":"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; }","tryCatchPattern":"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; }","preventionTips":["Only invoke user-scoped nodes within authenticated UI sessions.","For API/webhook-driven executions, prefer non-user-scoped stores.","Confirm your n8n version forwards additionalData.userId to the execution context.","Surface the missing-session condition early in the workflow, not deep in a memory node."],"tags":["auth","user-session","vector-store","memory","context"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}