mem0ai/mem0 · error · Error
${label} values must be finite numbers for Databricks vector
Error message
${label} values must be finite numbers for Databricks vector search. What it means
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.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/databricks.ts:1462
agent_id: any;
run_id: any;
} {
return {
user_id: payload.user_id,
agent_id: payload.agent_id,
run_id: payload.run_id,
};
}
private assertVectorDimension(vector: number[], label: string): void {
if (vector.length !== this.dimension) {
throw new Error(
`${label} dimension mismatch. Expected ${this.dimension}, got ${vector.length}`,
);
}
for (const value of vector) {
if (!Number.isFinite(value)) {
throw new Error(
`${label} values must be finite numbers for Databricks vector search.`,
);
}
}
}
private matchFieldCondition(
vector: DatabricksVector,
key: string,
value: any,
): boolean {
const fieldValue = key === "memory_id" ? vector.id : vector.payload[key];
if (typeof value !== "object" || value === null) {
if (value === "*") {
return true;
}
return fieldValue === value;View on GitHub (pinned to 001c235229)
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.
Example fix
// before
function normalize(v: number[]): number[] {
const norm = Math.sqrt(v.reduce((s, x) => s + x * x, 0));
return v.map((x) => x / norm); // norm=0 => NaN
}
// after
function normalize(v: number[]): number[] {
const norm = Math.sqrt(v.reduce((s, x) => s + x * x, 0));
if (!Number.isFinite(norm) || norm === 0) return v;
return v.map((x) => x / norm);
} Defensive patterns
Strategy: validation
Validate before calling
const allFinite = (v: number[]) => v.every(Number.isFinite);
if (!vectors.every(allFinite)) {
throw new Error('Embedding pipeline produced non-finite values; fix embedder before insert');
} Type guard
const isFiniteVector = (v: unknown): v is number[] => Array.isArray(v) && v.length > 0 && v.every((x) => typeof x === 'number' && Number.isFinite(x));
Try / catch
try {
await store.insert(vectors, ids, payloads);
} catch (e) {
if (e instanceof Error && e.message.includes('must be finite numbers')) {
// find and fix the NaN/Infinity source in the embedder; do not retry unchanged
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${label} dimension mismatch. Expected ${this.dimension}, got
- Unknown embedder provider: ${providerId}
- Langchain embedder provider requires an initialized Langchai
- Provided Langchain 'instance' in the 'model' field does not
- Invalid memory action: ${memoryAction}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/e7e3863c0c5e0aa1.
Report an issue: GitHub.