{"record":{"id":"6f2c97c641321b95","repo":"FlowiseAI/Flowise","slug":"user-id-field-cannot-be-empty-when-use-flowise-ch","errorCode":null,"errorMessage":"User ID field cannot be empty when \"Use Flowise Chat ID\" is OFF.","messagePattern":"User ID field cannot be empty when \"Use Flowise Chat ID\" is OFF\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/memory/Mem0/Mem0.ts","lineNumber":163,"sourceCode":"                default: 'text',\n                optional: true,\n                additionalParams: true\n            }\n        ]\n    }\n\n    async init(nodeData: INodeData, input: string, options: ICommonObject): Promise<any> {\n        return await initializeMem0(nodeData, input, options)\n    }\n}\n\nconst initializeMem0 = async (nodeData: INodeData, input: string, options: ICommonObject): Promise<BaseMem0Memory> => {\n    const initialUserId = nodeData.inputs?.user_id as string\n    const useFlowiseChatId = nodeData.inputs?.useFlowiseChatId as boolean\n    const orgId = options.orgId as string\n\n    if (!useFlowiseChatId && !initialUserId) {\n        throw new Error('User ID field cannot be empty when \"Use Flowise Chat ID\" is OFF.')\n    }\n\n    const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n    const apiKey = getCredentialParam('apiKey', credentialData, nodeData)\n\n    const mem0Options: ClientOptions = {\n        apiKey: apiKey,\n        host: nodeData.inputs?.host as string,\n        organizationId: nodeData.inputs?.org_id as string,\n        projectId: nodeData.inputs?.project_id as string\n    }\n\n    const memOptionsUserId = initialUserId\n\n    const constructorSessionId = initialUserId || (useFlowiseChatId ? 'flowise-chat-id-placeholder' : '')\n\n    const memoryOptions: MemoryOptions & SearchOptions = {\n        user_id: memOptionsUserId,","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/memory/Mem0/Mem0.ts#L145-L181","documentation":"Thrown by initializeMem0() at construction time when the 'Use Flowise Chat ID' toggle is OFF and the user_id input field is empty. Mem0 requires a stable user_id to scope memories; without the Flowise chat-id fallback, a missing user_id makes memory operations meaningless.","triggerScenarios":"Configuring the Mem0 node with useFlowiseChatId = false (or unset/falsy) and leaving the user_id input blank. Also if a falsy non-string value (0, null) is coerced.","commonSituations":"Operator disables the chat-id toggle expecting to supply their own ID, then forgets. Importing a chatflow that references an external user_id source that no longer exists. Misunderstanding the toggle semantics.","solutions":["Turn ON 'Use Flowise Chat ID' so the runtime chat ID is used automatically.","Or keep it OFF and populate the User ID input field with a concrete value or a variable reference that resolves to a non-empty string.","If driving user_id dynamically, ensure the upstream variable is set before init runs (it cannot be empty at init time)."],"exampleFix":"// before\ninputs: { useFlowiseChatId: false, user_id: '' }\n// after\ninputs: { useFlowiseChatId: false, user_id: 'user-42' }","handlingStrategy":"validation","validationCode":"function assertMem0UserIdInputs(inputs: { useFlowiseChatId?: unknown; user_id?: unknown }) {\n  const useFlowiseChatId = Boolean(inputs.useFlowiseChatId)\n  const userId = inputs.user_id\n  if (!useFlowiseChatId && (typeof userId !== 'string' || !userId)) {\n    throw new Error('Either enable \\'Use Flowise Chat ID\\' or supply a non-empty user_id.')\n  }\n}","typeGuard":"function hasValidMem0UserIdConfig(inputs: { useFlowiseChatId?: unknown; user_id?: unknown }): boolean {\n  return Boolean(inputs.useFlowiseChatId) || (typeof inputs.user_id === 'string' && inputs.user_id.length > 0)\n}","tryCatchPattern":"try {\n  await mem0Node.init(nodeData, input, options)\n} catch (e) {\n  if ((e as Error).message.includes('User ID field cannot be empty')) {\n    // prompt operator to enable the toggle or fill user_id\n  }\n  throw e\n}","preventionTips":["Document the toggle/user_id mutual requirement on the node's input tooltip.","Add a UI-level validator that blocks publish when both are unset.","Default 'Use Flowise Chat ID' to ON for chatflow templates."],"tags":["mem0","validation","configuration","user-id","memory"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}