{"record":{"id":"a4cde89380d905f4","repo":"FlowiseAI/Flowise","slug":"mem0-use-flowise-chat-id-is-on-but-no-runtime","errorCode":null,"errorMessage":"Mem0: \"Use Flowise Chat ID\" is ON, but no runtime chat ID (overrideUserId) was provided.","messagePattern":"Mem0: \"Use Flowise Chat ID\" is ON, but no runtime chat ID \\(overrideUserId\\) was provided\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/memory/Mem0/Mem0.ts","lineNumber":257,"sourceCode":"        this.inputKey = fields.inputKey ?? 'input'\n        this.appDataSource = fields.appDataSource\n        this.databaseEntities = fields.databaseEntities\n        this.chatflowid = fields.chatflowid\n        this.searchOnly = fields.searchOnly\n        this.useFlowiseChatId = fields.useFlowiseChatId\n        this.input = fields.input\n        this.orgId = fields.orgId\n    }\n\n    // Selects Mem0 user_id based on toggle state (Flowise chat ID or input field)\n    private getEffectiveUserId(overrideUserId?: string): string {\n        let effectiveUserId: string | undefined\n\n        if (this.useFlowiseChatId) {\n            if (overrideUserId) {\n                effectiveUserId = overrideUserId\n            } else {\n                throw new Error('Mem0: \"Use Flowise Chat ID\" is ON, but no runtime chat ID (overrideUserId) was provided.')\n            }\n        } else {\n            // If toggle is OFF, ALWAYS use the ID from the input field.\n            effectiveUserId = this.initialUserId\n        }\n\n        // This check is now primarily for the case where the toggle is OFF and the initialUserId was somehow empty (should be caught by init validation).\n        if (!effectiveUserId) {\n            throw new Error('Mem0: Could not determine a valid User ID for the operation. Check User ID input field.')\n        }\n        return effectiveUserId\n    }\n\n    async loadMemoryVariables(values: InputValues, overrideUserId = ''): Promise<MemoryVariables> {\n        const effectiveUserId = this.getEffectiveUserId(overrideUserId)\n        this.userId = effectiveUserId\n        if (this.memoryOptions) {\n            this.memoryOptions.user_id = effectiveUserId","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/memory/Mem0/Mem0.ts#L239-L275","documentation":"Thrown by Mem0MemoryExtended.getEffectiveUserId() at loadMemoryVariables time when useFlowiseChatId is ON but the overrideUserId argument passed in is empty/falsy. The toggle promises to use the runtime chat ID, so an empty override is treated as a hard error rather than silently defaulting.","triggerScenarios":"Calling loadMemoryVariables(values, overrideUserId) (or the SDK default of '') while useFlowiseChatId is true and no chat/session ID was propagated through overrideUserId. Happens when the chatflow is invoked through a path that does not set sessionId/chatId.","commonSituations":"Running the Mem0 node outside a chat session context (e.g. test harness, API call without sessionId). Upstream node not forwarding the chat ID. Override variable resolving to empty string.","solutions":["Ensure the calling chatflow/API passes a non-empty chat or session ID so overrideUserId is populated.","If you intend to use a fixed ID, turn OFF 'Use Flowise Chat ID' and set the User ID input instead.","Wire the override to a non-empty variable (e.g. $chatId) that is guaranteed at runtime.","In tests, pass a deterministic overrideUserId to loadMemoryVariables."],"exampleFix":"// before\nawait memory.loadMemoryVariables(values, '')  // toggle ON\n// after\nawait memory.loadMemoryVariables(values, sessionId || 'test-user')","handlingStrategy":"validation","validationCode":"function resolveMem0Override(useFlowiseChatId: boolean, overrideUserId: string, fallback: string): string {\n  if (useFlowiseChatId) {\n    if (!overrideUserId) throw new Error('sessionId/chatId must be provided when Use Flowise Chat ID is ON')\n    return overrideUserId\n  }\n  return fallback\n}","typeGuard":"function isNonEmptyUserId(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0\n}","tryCatchPattern":"try {\n  await memory.loadMemoryVariables(values, overrideUserId)\n} catch (e) {\n  if ((e as Error).message.includes('no runtime chat ID')) {\n    // wire a non-empty sessionId/chatId into overrideUserId before retrying\n  }\n  throw e\n}","preventionTips":["Always thread sessionId/chatId through to the memory node in API callers.","In tests, pass a deterministic overrideUserId.","UI: surface a warning when the toggle is ON but no chatId is wired."],"tags":["mem0","user-id","runtime","validation","memory"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}