mem0ai/mem0 · error · Error

Baidu Mochow table '${label}' exists but is missing the id/d

Error message

Baidu Mochow table '${label}' exists but is missing the id/data/vector/metadata schema mem0 requires. Drop it, or point 'tableName' at an unused table.

What it means

When the Baidu store finds the configured table already existing, it validates the schema mem0 requires: field id of STRING, data starting with TEXT, vector of FLOAT_VECTOR, metadata of JSON. If any is missing or of a different type, it throws telling you to drop the table or pick another tableName, because mem0 cannot adapt an incompatible table. This prevents silent data corruption of a foreign table.

Source

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

  private applySchema(preexisting: boolean, schema: TableSchema): void {
    if (!preexisting) {
      this.supportsKeywordSearch = true;
      return;
    }

    const fields = schema?.fields ?? [];
    const indexes = schema?.indexes ?? [];
    const field = (name: string) => fields.find((f) => f.fieldName === name);
    const typeOf = (name: string) => String(field(name)?.fieldType ?? "");
    const label = `${this.databaseName}.${this.tableName}`;

    if (
      typeOf("id") !== "STRING" ||
      !typeOf("data").startsWith("TEXT") ||
      typeOf("vector") !== "FLOAT_VECTOR" ||
      typeOf("metadata") !== "JSON"
    ) {
      throw new Error(
        `Baidu Mochow table '${label}' exists but is missing the id/data/vector/metadata schema mem0 requires. Drop it, or point 'tableName' at an unused table.`,
      );
    }

    const dimension = field("vector")?.dimension;
    if (dimension !== undefined && dimension !== this.embeddingModelDims) {
      throw new Error(
        `Baidu Mochow table '${label}' stores ${dimension}-dimensional vectors, but 'embeddingModelDims' is ${this.embeddingModelDims}.`,
      );
    }

    this.supportsKeywordSearch =
      typeOf("textLemmatized").startsWith("TEXT") &&
      indexes.some((index) => index.indexName === BM25_INDEX);

    if (!this.supportsKeywordSearch) {
      console.warn(
        `Baidu Mochow table '${label}' has no '${BM25_INDEX}' inverted index. keywordSearch() will return null until the table is recreated.`,

View on GitHub (pinned to 001c235229)

Solutions

  1. Drop the incompatible table (client.dropTable / console) and let mem0 recreate it with the correct schema.
  2. Or set tableName to a fresh, unused name.
  3. Back up any needed data before dropping; this store cannot migrate foreign schemas.

Example fix

// before
collectionName: 'shared_business_table'  // pre-existing, wrong schema
// after
collectionName: 'mem0_memories'  // fresh name, mem0 creates correct schema
Defensive patterns

Strategy: validation

Validate before calling

// Before first use, check the existing table's shape via descTable and compare:
// id: STRING, data: TEXT*, vector: FLOAT_VECTOR, metadata: JSON
async function tableIsMem0Compatible(desc: any): boolean {
  const t = (n: string) => String(desc?.schema?.fields?.find((f: any) => f.fieldName === n)?.fieldType ?? '');
  return t('id') === 'STRING' && t('data').startsWith('TEXT') && t('vector') === 'FLOAT_VECTOR' && t('metadata') === 'JSON';
}

Try / catch

try { new Memory(cfg) } catch (e) { if (e instanceof Error && /missing the id\/data\/vector\/metadata schema/.test(e.message)) { // halt: choose a new tableName or orchestrate a supervised drop+recreate } throw e; }

Prevention

When it happens

Trigger: Pointing tableName at a pre-existing Mochow table created by another app or an older mem0 schema; a table created for a different access pattern (e.g. vector stored as BINARY).

Common situations: Reusing a shared Baidu database; earlier manual experimentation left a table with a custom schema; mem0 schema evolution after upgrade.

Related errors


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