{"record":{"id":"e7e3863c0c5e0aa1","repo":"mem0ai/mem0","slug":"label-values-must-be-finite-numbers-for-databri","errorCode":null,"errorMessage":"${label} values must be finite numbers for Databricks vector search.","messagePattern":"(.+?) values must be finite numbers for Databricks vector search\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/databricks.ts","lineNumber":1462,"sourceCode":"    agent_id: any;\n    run_id: any;\n  } {\n    return {\n      user_id: payload.user_id,\n      agent_id: payload.agent_id,\n      run_id: payload.run_id,\n    };\n  }\n\n  private assertVectorDimension(vector: number[], label: string): void {\n    if (vector.length !== this.dimension) {\n      throw new Error(\n        `${label} dimension mismatch. Expected ${this.dimension}, got ${vector.length}`,\n      );\n    }\n    for (const value of vector) {\n      if (!Number.isFinite(value)) {\n        throw new Error(\n          `${label} values must be finite numbers for Databricks vector search.`,\n        );\n      }\n    }\n  }\n\n  private matchFieldCondition(\n    vector: DatabricksVector,\n    key: string,\n    value: any,\n  ): boolean {\n    const fieldValue = key === \"memory_id\" ? vector.id : vector.payload[key];\n\n    if (typeof value !== \"object\" || value === null) {\n      if (value === \"*\") {\n        return true;\n      }\n      return fieldValue === value;","sourceCodeStart":1444,"sourceCodeEnd":1480,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/databricks.ts#L1444-L1480","documentation":"assertVectorDimension() throws when any component of a vector is NaN, Infinity, or -Infinity. Databricks Vector Search (and most ANN indexes) cannot index non-finite floats; sending them would either corrupt the index or fail opaquely server-side, so the provider rejects them up front.","triggerScenarios":"Calling insert()/update() with vectors containing NaN or Infinity — typically the output of a broken embedding function (division by zero, log of negative, uninitialized model weights) or corrupted data read from a file/DB.","commonSituations":"Custom or local embedding implementations that emit NaN for empty or malformed input text; JSON parsing of Infinity (JSON has no representation, producing undefined math downstream); FP overflow in a hand-rolled embedding pipeline; tokenizer returning empty sequence leading to 0/0 normalization.","solutions":["Inspect the embedding function: log Number.isFinite checks over outputs to find which inputs produce NaN/Infinity.","Guard the embedder for empty/invalid input text before embedding (return early or embed a placeholder).","If vectors are transported via JSON, ensure no NaN was serialized as null/undefined and then coerced.","Fix normalization code that divides by a zero norm."],"exampleFix":"// before\nfunction normalize(v: number[]): number[] {\n  const norm = Math.sqrt(v.reduce((s, x) => s + x * x, 0));\n  return v.map((x) => x / norm); // norm=0 => NaN\n}\n\n// after\nfunction normalize(v: number[]): number[] {\n  const norm = Math.sqrt(v.reduce((s, x) => s + x * x, 0));\n  if (!Number.isFinite(norm) || norm === 0) return v;\n  return v.map((x) => x / norm);\n}","handlingStrategy":"validation","validationCode":"const allFinite = (v: number[]) => v.every(Number.isFinite);\nif (!vectors.every(allFinite)) {\n  throw new Error('Embedding pipeline produced non-finite values; fix embedder before insert');\n}","typeGuard":"const isFiniteVector = (v: unknown): v is number[] =>\n  Array.isArray(v) && v.length > 0 && v.every((x) => typeof x === 'number' && Number.isFinite(x));","tryCatchPattern":"try {\n  await store.insert(vectors, ids, payloads);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('must be finite numbers')) {\n    // find and fix the NaN/Infinity source in the embedder; do not retry unchanged\n  }\n  throw e;\n}","preventionTips":["Guard embedding normalization against zero norms and empty inputs.","Validate embedder output with Number.isFinite in tests.","Never transport vectors through lossy JSON paths that cannot represent non-finite values."],"tags":["databricks","nan","embeddings","validation","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}