{"record":{"id":"26a928f205bb6287","repo":"ruvnet/ruflo","slug":"embedding-dimensions-must-match","errorCode":null,"errorMessage":"Embedding dimensions must match","messagePattern":"Embedding dimensions must match","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/embeddings/src/embedding-service.ts","lineNumber":1094,"sourceCode":"    return result.embedding;\n  } finally {\n    await service.shutdown();\n  }\n}\n\n// ============================================================================\n// Similarity Functions\n// ============================================================================\n\n/**\n * Compute cosine similarity between two embeddings\n */\nexport function cosineSimilarity(\n  a: Float32Array | number[],\n  b: Float32Array | number[]\n): number {\n  if (a.length !== b.length) {\n    throw new Error('Embedding dimensions must match');\n  }\n\n  let dot = 0;\n  let normA = 0;\n  let normB = 0;\n\n  for (let i = 0; i < a.length; i++) {\n    dot += a[i] * b[i];\n    normA += a[i] * a[i];\n    normB += b[i] * b[i];\n  }\n\n  const denom = Math.sqrt(normA) * Math.sqrt(normB);\n  return denom > 0 ? dot / denom : 0;\n}\n\n/**\n * Compute Euclidean distance between two embeddings","sourceCodeStart":1076,"sourceCodeEnd":1112,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/embeddings/src/embedding-service.ts#L1076-L1112","documentation":"cosineSimilarity() received two embedding vectors of different lengths. The dot product and norms are only meaningful for aligned dimensions, so the mismatch is rejected up front — usually embeddings from two different models or a truncated vector.","triggerScenarios":"Thrown at v3/@claude-flow/embeddings/src/embedding-service.ts:1094 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Embed all compared texts with the same model and provider so dimensions match.","Do not mix vectors from caches built with different models; clear the cache after switching models."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}