FlowiseAI/Flowise · error · Error

User ID field cannot be empty when "Use Flowise Chat ID" is

Error message

User ID field cannot be empty when "Use Flowise Chat ID" is OFF.

What it means

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.

Source

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

                default: 'text',
                optional: true,
                additionalParams: true
            }
        ]
    }

    async init(nodeData: INodeData, input: string, options: ICommonObject): Promise<any> {
        return await initializeMem0(nodeData, input, options)
    }
}

const initializeMem0 = async (nodeData: INodeData, input: string, options: ICommonObject): Promise<BaseMem0Memory> => {
    const initialUserId = nodeData.inputs?.user_id as string
    const useFlowiseChatId = nodeData.inputs?.useFlowiseChatId as boolean
    const orgId = options.orgId as string

    if (!useFlowiseChatId && !initialUserId) {
        throw new Error('User ID field cannot be empty when "Use Flowise Chat ID" is OFF.')
    }

    const credentialData = await getCredentialData(nodeData.credential ?? '', options)
    const apiKey = getCredentialParam('apiKey', credentialData, nodeData)

    const mem0Options: ClientOptions = {
        apiKey: apiKey,
        host: nodeData.inputs?.host as string,
        organizationId: nodeData.inputs?.org_id as string,
        projectId: nodeData.inputs?.project_id as string
    }

    const memOptionsUserId = initialUserId

    const constructorSessionId = initialUserId || (useFlowiseChatId ? 'flowise-chat-id-placeholder' : '')

    const memoryOptions: MemoryOptions & SearchOptions = {
        user_id: memOptionsUserId,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Turn ON 'Use Flowise Chat ID' so the runtime chat ID is used automatically.
  2. 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.
  3. If driving user_id dynamically, ensure the upstream variable is set before init runs (it cannot be empty at init time).

Example fix

// before
inputs: { useFlowiseChatId: false, user_id: '' }
// after
inputs: { useFlowiseChatId: false, user_id: 'user-42' }
Defensive patterns

Strategy: validation

Validate before calling

function assertMem0UserIdInputs(inputs: { useFlowiseChatId?: unknown; user_id?: unknown }) {
  const useFlowiseChatId = Boolean(inputs.useFlowiseChatId)
  const userId = inputs.user_id
  if (!useFlowiseChatId && (typeof userId !== 'string' || !userId)) {
    throw new Error('Either enable \'Use Flowise Chat ID\' or supply a non-empty user_id.')
  }
}

Type guard

function hasValidMem0UserIdConfig(inputs: { useFlowiseChatId?: unknown; user_id?: unknown }): boolean {
  return Boolean(inputs.useFlowiseChatId) || (typeof inputs.user_id === 'string' && inputs.user_id.length > 0)
}

Try / catch

try {
  await mem0Node.init(nodeData, input, options)
} catch (e) {
  if ((e as Error).message.includes('User ID field cannot be empty')) {
    // prompt operator to enable the toggle or fill user_id
  }
  throw e
}

Prevention

When it happens

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

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

Related errors


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