mem0ai/mem0 · error · Error

Index parameter '${key}' must be an integer between ${range[

Error message

Index parameter '${key}' must be an integer between ${range[0]} and ${range[1]}

What it means

Beyond key validation (error 274), every index parameter value must be an integer inside the type-specific range from INDEX_PARAMETER_RANGES: HNSW neighbors 2–2048, efconstruction 1–65535; IVF neighbor partitions 1–10000000, samples_per_partition 1–MAX_SAFE_INTEGER, min_vectors_per_partition 0–MAX_SAFE_INTEGER.

Source

Thrown at mem0-ts/src/oss/src/vector_stores/oracledb.ts:392

  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) {
        throw new Error(
          `Unsupported ${this.indexType} index parameter '${key}'. ` +
            `Allowed: ${Object.keys(allowed).join(", ")}`,
        );
      }
      if (!Number.isInteger(value) || value < range[0] || value > range[1]) {
        throw new Error(
          `Index parameter '${key}' must be an integer between ${range[0]} and ${range[1]}`,
        );
      }
      validated[key] = value;
    }

    return validated;
  }

  async initialize(): Promise<void> {
    if (!this._initPromise) {
      this._initPromise = this._doInitialize().catch(async (error) => {
        if (this.ownsClient && this.client) {
          await Promise.resolve(this.client.close()).catch(() => {});
          this.client = undefined;
          this.ownsClient = false;
        }
        this._initPromise = undefined;

View on GitHub (pinned to 001c235229)

Solutions

  1. Clamp to the documented ranges: neighbors 2–2048, efconstruction 1–65535, neighbor partitions ≥ 1.
  2. Round non-integers: Math.max(min, Math.min(max, Math.round(v))).
  3. Validate env-sourced numbers with Number.isInteger before passing them in.
  4. If unsure, omit indexParameters — Oracle applies sensible defaults.

Example fix

// before
indexParameters: { neighbors: 1, efconstruction: 0 }

// after
indexParameters: { neighbors: 32, efconstruction: 400 }
Defensive patterns

Strategy: validation

Validate before calling

function clampInt(name: string, v: number, [min, max]: [number, number]): number {
  const n = Math.round(v);
  if (n < min || n > max) throw new RangeError(`${name}=${v} out of range [${min}, ${max}]`);
  return n;
}

Type guard

const inRange = (v: unknown, min: number, max: number): v is number => typeof v === 'number' && Number.isInteger(v) && v >= min && v <= max;

Prevention

When it happens

Trigger: HNSW { neighbors: 1 } (below minimum 2); { efconstruction: 0 }; IVF { 'neighbor partitions': 0 }; non-integer values like { neighbors: 64.5 }; values parsed from env strings producing NaN.

Common situations: Aggressive tuning experiments (neighbors=1, efconstruction=0) that fall below Oracle's legal bounds; float math on config values; copy-pasted numbers from other engines whose ranges differ (e.g. pgvector's ef_construction can be small but Oracle's floor is 1).

Related errors


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