{"record":{"id":"b4d07a6ac703a716","repo":"mem0ai/mem0","slug":"unsupported-distance-metric-config-distancemetr","errorCode":null,"errorMessage":"Unsupported distance metric: ${config.distanceMetric}","messagePattern":"Unsupported distance metric: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/vector_stores/oracledb.ts","lineNumber":351,"sourceCode":"\n    this.collectionName = quoteIdentifier(config.collectionName || \"mem0\");\n    this.indexName = quoteIdentifier(\n      config.indexName || `${config.collectionName || \"mem0\"}_VEC_IDX`,\n    );\n\n    this.embeddingModelDims = config.embeddingModelDims ?? 1536;\n    if (\n      !Number.isInteger(this.embeddingModelDims) ||\n      this.embeddingModelDims <= 0\n    ) {\n      throw new Error(\"`embeddingModelDims` must be a positive integer\");\n    }\n\n    const distanceMetric = (config.distanceMetric ??\n      \"COSINE\") as string as DistanceMetric;\n    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","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/vector_stores/oracledb.ts#L333-L369","documentation":"The distance metric is stored in the vector index DDL and used to convert distance to a similarity score, so it must be one of the six supported Oracle VECTOR_DISTANCE functions: COSINE, EUCLIDEAN, EUCLIDEAN_SQUARED, DOT, HAMMING, MANHATTAN. The value is uppercased before the check, so 'cosine' is accepted; anything else fails, echoing the original config value in the message.","triggerScenarios":"distanceMetric: 'euclidean' works (uppercased) but 'l2' fails; 'cosine-similarity', 'IP' (a Qdrant name), 'l2_sq' (pgvector name), or undefined-typo metrics fail. Note the message prints the raw config value, e.g. \"Unsupported distance metric: l2\".","commonSituations":"Porting configs from other vector stores: Qdrant uses 'Cosine'/'Dot'/'Euclid', pgvector uses '<->' or 'l2'; misspellings like 'COSIN'; binary-embedding setups where 'hamming' is correct but users type 'hamming-distance'.","solutions":["Use one of: COSINE, EUCLIDEAN, EUCLIDEAN_SQUARED, DOT, HAMMING, MANHATTAN (case-insensitive).","Map other backends' names: Qdrant 'Dot' → DOT, 'Euclid' → EUCLIDEAN; pgvector 'l2' → EUCLIDEAN, '<#>' → DOT.","Omit distanceMetric to get the COSINE default, which matches most normalized-embedding setups.","If porting a config file, grep it for old metric names before switching stores."],"exampleFix":"// before\nnew OracleDB({ connectionParams, distanceMetric: 'l2' });\n\n// after\nnew OracleDB({ connectionParams, distanceMetric: 'EUCLIDEAN' });","handlingStrategy":"validation","validationCode":"const ORACLE_METRICS = new Set(['COSINE','EUCLIDEAN','EUCLIDEAN_SQUARED','DOT','HAMMING','MANHATTAN']);\nfunction normalizeMetric(m?: string): string | undefined {\n  if (!m) return undefined;\n  const upper = m.toUpperCase();\n  if (!ORACLE_METRICS.has(upper)) throw new RangeError(`Unsupported distance metric '${m}'. Valid: ${[...ORACLE_METRICS].join(', ')}`);\n  return upper;\n}","typeGuard":"const isOracleMetric = (v: string): v is 'COSINE'|'EUCLIDEAN'|'EUCLIDEAN_SQUARED'|'DOT'|'HAMMING'|'MANHATTAN' => ORACLE_METRICS.has(v.toUpperCase());","tryCatchPattern":null,"preventionTips":["Translate metric names when porting configs from Qdrant/pgvector (Dot→DOT, l2→EUCLIDEAN).","Default to COSINE for normalized embeddings and omit the option."],"tags":["oracle","config","distance-metric","validation","constructor"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}