{"record":{"id":"7050af8bd4c27698","repo":"mem0ai/mem0","slug":"baidu-vector-store-requires-a-non-empty-name","errorCode":null,"errorMessage":"Baidu vector store requires a non-empty '${name}' config value.","messagePattern":"Baidu vector store requires a non-empty '(.+?)' config value\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/baidu.ts","lineNumber":143,"sourceCode":"    const requiredFields: Array<\n      readonly [string, string | number | undefined]\n    > = [\n      [\"databaseName\", this.databaseName],\n      [\"tableName\", this.tableName],\n      [\"embeddingModelDims\", this.embeddingModelDims],\n    ];\n\n    if (!this.client) {\n      requiredFields.unshift(\n        [\"endpoint\", this.endpoint],\n        [\"account\", this.account],\n        [\"apiKey\", this.apiKey],\n      );\n    }\n\n    for (const [name, value] of requiredFields) {\n      if (value === undefined || value === null || value === \"\") {\n        throw new Error(\n          `Baidu vector store requires a non-empty '${name}' config value.`,\n        );\n      }\n    }\n\n    this.initialize().catch(console.error);\n  }\n\n  private get ns(): { database: string; table: string } {\n    return { database: this.databaseName, table: this.tableName };\n  }\n\n  // Loaded dynamically: @mochow/mochow-sdk-node is an optional peer dependency, so a static\n  // value import would break `import { Memory } from \"mem0ai/oss\"` for everyone else.\n  private async loadSdk(): Promise<MochowSdk> {\n    if (!this.sdk) {\n      const module: MochowSdk & { default?: MochowSdk } = await loadPeer(\n        \"@mochow/mochow-sdk-node\",","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/baidu.ts#L125-L161","documentation":"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).","triggerScenarios":"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.","commonSituations":"Env var name typo (BAIDU_ENDPOINT vs BAIDU_API_ENDPOINT); secrets stripped in CI; config objects built conditionally where fields end up undefined.","solutions":["Set the named field from the error message to a non-empty string (Baidu Mochow endpoint URL, account, apiKey, database name, table name).","Check env var spelling and that secrets are actually present in the runtime environment (never empty strings).","Validate config before constructing Memory (see validation snippet) to fail with your own message."],"exampleFix":"// before\nconfig: { endpoint: process.env.BAIDU_ENDPOINT, account: 'acct', apiKey: key } // BAIDU_ENDPOINT unset\n// after\nconfig: { endpoint: 'https://mochow.bc.bcebos.com/v1', account: 'acct', apiKey: key }","handlingStrategy":"validation","validationCode":"function validateBaiduConfig(c: Record<string, unknown>) {\n  for (const f of ['endpoint','account','apiKey','databaseName','tableName']) {\n    const v = c[f];\n    if (typeof v !== 'string' || v === '') throw new Error(`Missing required Baidu config '${f}'`);\n  }\n}","typeGuard":"const hasBaiduRequired = (c: any): boolean =>\n  ['endpoint','account','apiKey','databaseName','tableName'].every(k => typeof c?.[k] === 'string' && c[k] !== '');","tryCatchPattern":"try { new Memory(cfg) } catch (e) { if (e instanceof Error && /requires a non-empty/.test(e.message)) { /* surface the named missing field */ } throw e; }","preventionTips":["Load and assert all Baidu env vars at process start with a fail-fast config module.","Treat undefined from process.env as an error, not an empty string."],"tags":["baidu","configuration","validation","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}