{"record":{"id":"56f7266d392a9399","repo":"mem0ai/mem0","slug":"indexaccuracy-must-be-an-integer-between-1-and-1","errorCode":null,"errorMessage":"`indexAccuracy` must be an integer between 1 and 100","messagePattern":"`indexAccuracy` must be an integer between 1 and 100","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/oracledb.ts","lineNumber":367,"sourceCode":"    this.distanceMetric = distanceMetric.toUpperCase() as DistanceMetric;\n    if (!DISTANCE_METRICS.includes(this.distanceMetric)) {\n      throw new Error(`Unsupported distance metric: ${config.distanceMetric}`);\n    }\n\n    const indexType = (config.indexType ?? \"HNSW\") as string;\n    this.indexType = indexType.toUpperCase() as IndexType;\n    if (this.indexType !== \"HNSW\" && this.indexType !== \"IVF\") {\n      throw new Error(`Unsupported index type: ${config.indexType}`);\n    }\n\n    this.indexAccuracy = config.indexAccuracy;\n    if (\n      this.indexAccuracy !== undefined &&\n      (!Number.isInteger(this.indexAccuracy) ||\n        this.indexAccuracy <= 0 ||\n        this.indexAccuracy > 100)\n    ) {\n      throw new Error(\"`indexAccuracy` must be an integer between 1 and 100\");\n    }\n\n    this.indexParameters = this.validateIndexParameters(config.indexParameters);\n    this.doCreateIndex = config.doCreateIndex ?? true;\n    this.config = config;\n  }\n\n  private validateIndexParameters(\n    parameters?: Record<string, number>,\n  ): Record<string, number> {\n    if (!parameters) return {};\n\n    const allowed = INDEX_PARAMETER_RANGES[this.indexType];\n    const validated: Record<string, number> = {};\n\n    for (const [key, value] of Object.entries(parameters)) {\n      const range = allowed[key];\n      if (!range) {","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/oracledb.ts#L349-L385","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnew OracleDB({ connectionParams, indexAccuracy: 0.95 }); // fraction -> throws\n\n// after\nnew OracleDB({ connectionParams, indexAccuracy: 95 });","handlingStrategy":"validation","validationCode":"function parseAccuracy(raw: string | number | undefined): number | undefined {\n  if (raw === undefined || raw === '') return undefined;\n  const n = typeof raw === 'string' ? parseInt(raw, 10) : raw;\n  if (!Number.isInteger(n) || n < 1 || n > 100) throw new RangeError(`indexAccuracy must be an integer 1-100, got ${String(raw)}`);\n  return n;\n}","typeGuard":"const isValidAccuracy = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 1 && v <= 100;","tryCatchPattern":null,"preventionTips":["Remember accuracy is a percentage (1–100), not a 0–1 fraction.","Omit the option to accept Oracle's default."],"tags":["oracle","config","index","validation","constructor"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}