{"record":{"id":"5a91918bd2d1ca59","repo":"mem0ai/mem0","slug":"baidu-mochow-table-label-exists-but-is-missin","errorCode":null,"errorMessage":"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.","messagePattern":"Baidu Mochow table '(.+?)' exists but is missing the id/data/vector/metadata schema mem0 requires\\. Drop it, or point 'tableName' at an unused table\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/baidu.ts","lineNumber":370,"sourceCode":"  private applySchema(preexisting: boolean, schema: TableSchema): void {\n    if (!preexisting) {\n      this.supportsKeywordSearch = true;\n      return;\n    }\n\n    const fields = schema?.fields ?? [];\n    const indexes = schema?.indexes ?? [];\n    const field = (name: string) => fields.find((f) => f.fieldName === name);\n    const typeOf = (name: string) => String(field(name)?.fieldType ?? \"\");\n    const label = `${this.databaseName}.${this.tableName}`;\n\n    if (\n      typeOf(\"id\") !== \"STRING\" ||\n      !typeOf(\"data\").startsWith(\"TEXT\") ||\n      typeOf(\"vector\") !== \"FLOAT_VECTOR\" ||\n      typeOf(\"metadata\") !== \"JSON\"\n    ) {\n      throw new Error(\n        `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.`,\n      );\n    }\n\n    const dimension = field(\"vector\")?.dimension;\n    if (dimension !== undefined && dimension !== this.embeddingModelDims) {\n      throw new Error(\n        `Baidu Mochow table '${label}' stores ${dimension}-dimensional vectors, but 'embeddingModelDims' is ${this.embeddingModelDims}.`,\n      );\n    }\n\n    this.supportsKeywordSearch =\n      typeOf(\"textLemmatized\").startsWith(\"TEXT\") &&\n      indexes.some((index) => index.indexName === BM25_INDEX);\n\n    if (!this.supportsKeywordSearch) {\n      console.warn(\n        `Baidu Mochow table '${label}' has no '${BM25_INDEX}' inverted index. keywordSearch() will return null until the table is recreated.`,","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/baidu.ts#L352-L388","documentation":"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.","triggerScenarios":"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).","commonSituations":"Reusing a shared Baidu database; earlier manual experimentation left a table with a custom schema; mem0 schema evolution after upgrade.","solutions":["Drop the incompatible table (client.dropTable / console) and let mem0 recreate it with the correct schema.","Or set tableName to a fresh, unused name.","Back up any needed data before dropping; this store cannot migrate foreign schemas."],"exampleFix":"// before\ncollectionName: 'shared_business_table'  // pre-existing, wrong schema\n// after\ncollectionName: 'mem0_memories'  // fresh name, mem0 creates correct schema","handlingStrategy":"validation","validationCode":"// Before first use, check the existing table's shape via descTable and compare:\n// id: STRING, data: TEXT*, vector: FLOAT_VECTOR, metadata: JSON\nasync function tableIsMem0Compatible(desc: any): boolean {\n  const t = (n: string) => String(desc?.schema?.fields?.find((f: any) => f.fieldName === n)?.fieldType ?? '');\n  return t('id') === 'STRING' && t('data').startsWith('TEXT') && t('vector') === 'FLOAT_VECTOR' && t('metadata') === 'JSON';\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Dedicate a table (and database) to mem0 instead of sharing with other apps.","Include the schema check in provisioning scripts so incompatibility is caught pre-deploy.","Never auto-drop on this error in production without a data backup step."],"tags":["baidu","mochow","schema-mismatch","vector-store","table"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}