mem0ai/mem0 · error · Error

Baidu vector store requires a non-empty '${name}' config val

Error message

Baidu vector store requires a non-empty '${name}' config value.

What it means

The Baidu vector store constructor validates required config values (endpoint, account, apiKey always; database/table via the requiredFields list when no client is injected) and throws naming the first empty one. This fails fast at construction instead of deep inside an SDK call. Values must be non-empty strings (undefined, null, and '' all fail).

Source

Thrown at mem0-ts/src/oss/src/vector_stores/baidu.ts:143

    const requiredFields: Array<
      readonly [string, string | number | undefined]
    > = [
      ["databaseName", this.databaseName],
      ["tableName", this.tableName],
      ["embeddingModelDims", this.embeddingModelDims],
    ];

    if (!this.client) {
      requiredFields.unshift(
        ["endpoint", this.endpoint],
        ["account", this.account],
        ["apiKey", this.apiKey],
      );
    }

    for (const [name, value] of requiredFields) {
      if (value === undefined || value === null || value === "") {
        throw new Error(
          `Baidu vector store requires a non-empty '${name}' config value.`,
        );
      }
    }

    this.initialize().catch(console.error);
  }

  private get ns(): { database: string; table: string } {
    return { database: this.databaseName, table: this.tableName };
  }

  // Loaded dynamically: @mochow/mochow-sdk-node is an optional peer dependency, so a static
  // value import would break `import { Memory } from "mem0ai/oss"` for everyone else.
  private async loadSdk(): Promise<MochowSdk> {
    if (!this.sdk) {
      const module: MochowSdk & { default?: MochowSdk } = await loadPeer(
        "@mochow/mochow-sdk-node",

View on GitHub (pinned to 001c235229)

Solutions

  1. Set the named field from the error message to a non-empty string (Baidu Mochow endpoint URL, account, apiKey, database name, table name).
  2. Check env var spelling and that secrets are actually present in the runtime environment (never empty strings).
  3. Validate config before constructing Memory (see validation snippet) to fail with your own message.

Example fix

// before
config: { endpoint: process.env.BAIDU_ENDPOINT, account: 'acct', apiKey: key } // BAIDU_ENDPOINT unset
// after
config: { endpoint: 'https://mochow.bc.bcebos.com/v1', account: 'acct', apiKey: key }
Defensive patterns

Strategy: validation

Validate before calling

function validateBaiduConfig(c: Record<string, unknown>) {
  for (const f of ['endpoint','account','apiKey','databaseName','tableName']) {
    const v = c[f];
    if (typeof v !== 'string' || v === '') throw new Error(`Missing required Baidu config '${f}'`);
  }
}

Type guard

const hasBaiduRequired = (c: any): boolean =>
  ['endpoint','account','apiKey','databaseName','tableName'].every(k => typeof c?.[k] === 'string' && c[k] !== '');

Try / catch

try { new Memory(cfg) } catch (e) { if (e instanceof Error && /requires a non-empty/.test(e.message)) { /* surface the named missing field */ } throw e; }

Prevention

When it happens

Trigger: new Memory({ vectorStore: { provider: 'baidu', config: { endpoint: '', account: 'x', apiKey: 'y' } } }); reading config from env vars that are unset so they arrive as undefined; passing tableName but not database.

Common situations: Env var name typo (BAIDU_ENDPOINT vs BAIDU_API_ENDPOINT); secrets stripped in CI; config objects built conditionally where fields end up undefined.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/7050af8bd4c27698. Report an issue: GitHub.