FlowiseAI/Flowise · error · Error

Mem0: "Use Flowise Chat ID" is ON, but no runtime chat ID (o

Error message

Mem0: "Use Flowise Chat ID" is ON, but no runtime chat ID (overrideUserId) was provided.

What it means

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.

Source

Thrown at packages/components/nodes/memory/Mem0/Mem0.ts:257

        this.inputKey = fields.inputKey ?? 'input'
        this.appDataSource = fields.appDataSource
        this.databaseEntities = fields.databaseEntities
        this.chatflowid = fields.chatflowid
        this.searchOnly = fields.searchOnly
        this.useFlowiseChatId = fields.useFlowiseChatId
        this.input = fields.input
        this.orgId = fields.orgId
    }

    // Selects Mem0 user_id based on toggle state (Flowise chat ID or input field)
    private getEffectiveUserId(overrideUserId?: string): string {
        let effectiveUserId: string | undefined

        if (this.useFlowiseChatId) {
            if (overrideUserId) {
                effectiveUserId = overrideUserId
            } else {
                throw new Error('Mem0: "Use Flowise Chat ID" is ON, but no runtime chat ID (overrideUserId) was provided.')
            }
        } else {
            // If toggle is OFF, ALWAYS use the ID from the input field.
            effectiveUserId = this.initialUserId
        }

        // 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).
        if (!effectiveUserId) {
            throw new Error('Mem0: Could not determine a valid User ID for the operation. Check User ID input field.')
        }
        return effectiveUserId
    }

    async loadMemoryVariables(values: InputValues, overrideUserId = ''): Promise<MemoryVariables> {
        const effectiveUserId = this.getEffectiveUserId(overrideUserId)
        this.userId = effectiveUserId
        if (this.memoryOptions) {
            this.memoryOptions.user_id = effectiveUserId

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Ensure the calling chatflow/API passes a non-empty chat or session ID so overrideUserId is populated.
  2. If you intend to use a fixed ID, turn OFF 'Use Flowise Chat ID' and set the User ID input instead.
  3. Wire the override to a non-empty variable (e.g. $chatId) that is guaranteed at runtime.
  4. In tests, pass a deterministic overrideUserId to loadMemoryVariables.

Example fix

// before
await memory.loadMemoryVariables(values, '')  // toggle ON
// after
await memory.loadMemoryVariables(values, sessionId || 'test-user')
Defensive patterns

Strategy: validation

Validate before calling

function resolveMem0Override(useFlowiseChatId: boolean, overrideUserId: string, fallback: string): string {
  if (useFlowiseChatId) {
    if (!overrideUserId) throw new Error('sessionId/chatId must be provided when Use Flowise Chat ID is ON')
    return overrideUserId
  }
  return fallback
}

Type guard

function isNonEmptyUserId(v: unknown): v is string {
  return typeof v === 'string' && v.trim().length > 0
}

Try / catch

try {
  await memory.loadMemoryVariables(values, overrideUserId)
} catch (e) {
  if ((e as Error).message.includes('no runtime chat ID')) {
    // wire a non-empty sessionId/chatId into overrideUserId before retrying
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/a4cde89380d905f4. Report an issue: GitHub.