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

  1. Use an integer 1–100, e.g. 95 for 95% target accuracy; convert 0.95 → 95.
  2. Omit indexAccuracy to let Oracle pick its default.
  3. Validate env-sourced values: const acc = env ? parseInt(env, 10) : undefined.
  4. 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

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


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/56f7266d392a9399. Report an issue: GitHub.