mem0ai/mem0 · error · Error
`indexAccuracy` must be an integer between 1 and 100
Error message
`indexAccuracy` must be an integer between 1 and 100
What it means
indexAccuracy maps to the 'WITH TARGET ACCURACY n' clause of CREATE VECTOR INDEX, whose legal Oracle range is 1–100 (a percentage). The adapter validates it only when provided (undefined is allowed and omits the clause); non-integers, zero, negatives, and values above 100 fail Number.isInteger/range checks.
Source
Thrown at mem0-ts/src/oss/src/vector_stores/oracledb.ts:367
this.distanceMetric = distanceMetric.toUpperCase() as DistanceMetric;
if (!DISTANCE_METRICS.includes(this.distanceMetric)) {
throw new Error(`Unsupported distance metric: ${config.distanceMetric}`);
}
const indexType = (config.indexType ?? "HNSW") as string;
this.indexType = indexType.toUpperCase() as IndexType;
if (this.indexType !== "HNSW" && this.indexType !== "IVF") {
throw new Error(`Unsupported index type: ${config.indexType}`);
}
this.indexAccuracy = config.indexAccuracy;
if (
this.indexAccuracy !== undefined &&
(!Number.isInteger(this.indexAccuracy) ||
this.indexAccuracy <= 0 ||
this.indexAccuracy > 100)
) {
throw new Error("`indexAccuracy` must be an integer between 1 and 100");
}
this.indexParameters = this.validateIndexParameters(config.indexParameters);
this.doCreateIndex = config.doCreateIndex ?? true;
this.config = config;
}
private validateIndexParameters(
parameters?: Record<string, number>,
): Record<string, number> {
if (!parameters) return {};
const allowed = INDEX_PARAMETER_RANGES[this.indexType];
const validated: Record<string, number> = {};
for (const [key, value] of Object.entries(parameters)) {
const range = allowed[key];
if (!range) {View on GitHub (pinned to 001c235229)
Solutions
- Use an integer 1–100, e.g. 95 for 95% target accuracy; convert 0.95 → 95.
- Omit indexAccuracy to let Oracle pick its default.
- Validate env-sourced values: const acc = env ? parseInt(env, 10) : undefined.
- Remember it applies only when doCreateIndex is true and applies to HNSW/IVF target accuracy.
Example fix
// before
new OracleDB({ connectionParams, indexAccuracy: 0.95 }); // fraction -> throws
// after
new OracleDB({ connectionParams, indexAccuracy: 95 }); Defensive patterns
Strategy: validation
Validate before calling
function parseAccuracy(raw: string | number | undefined): number | undefined {
if (raw === undefined || raw === '') return undefined;
const n = typeof raw === 'string' ? parseInt(raw, 10) : raw;
if (!Number.isInteger(n) || n < 1 || n > 100) throw new RangeError(`indexAccuracy must be an integer 1-100, got ${String(raw)}`);
return n;
} Type guard
const isValidAccuracy = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 100;
Prevention
- Remember accuracy is a percentage (1–100), not a 0–1 fraction.
- Omit the option to accept Oracle's default.
When it happens
Trigger: indexAccuracy: 0.95 (a 0–1 float, the common mistake — this is a percentage, not a fraction); indexAccuracy: 0 (means 'no accuracy', invalid); indexAccuracy: 150; values parsed from strings like '85' becoming '85' the string.
Common situations: Developers porting recall/accuracy settings from other systems expressed as 0–1 fractions; supplying 100 assuming 'maximum' works (it does — 100 is valid — but 101 fails); env-var configs that yield strings or NaN.
Related errors
- Unsupported index type: ${config.indexType}
- Must provide at least one of `connectionParams` and `client`
- `embeddingModelDims` must be a positive integer
- Unsupported distance metric: ${config.distanceMetric}
- Unsupported ${this.indexType} index parameter '${key}'. Allo
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/56f7266d392a9399.
Report an issue: GitHub.