{"record":{"id":"5b4177942feb84b1","repo":"ruvnet/ruflo","slug":"vector-must-be-a-non-empty-numeric-array","errorCode":null,"errorMessage":"vector must be a non-empty numeric array","messagePattern":"vector must be a non-empty numeric array","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts","lineNumber":172,"sourceCode":"    tags: ['agenticow', 'memory', 'cow', 'query', 'read', 'search'],\n    inputSchema: {\n      type: 'object',\n      properties: {\n        path: { type: 'string', description: 'Path to .rvf memory file' },\n        vector: { type: 'array', items: { type: 'number' }, description: 'Query embedding vector' },\n        k: { type: 'integer', description: 'Number of nearest neighbors to return', default: 10 },\n        efSearch: { type: 'integer', description: 'HNSW efSearch per lineage store (higher = better recall, slower)' },\n      },\n      required: ['path', 'vector'],\n    },\n    handler: async (input) => {\n      const api = await loadAgenticow();\n      if (!api) return degradedResult('agenticow-not-found');\n\n      const path = resolveMemoryPath(String(input.path));\n      const vector = input.vector as number[];\n      if (!Array.isArray(vector) || vector.length === 0) {\n        throw new Error('vector must be a non-empty numeric array');\n      }\n      const k = typeof input.k === 'number' ? input.k : 10;\n      const opts: Record<string, unknown> = {};\n      if (typeof input.efSearch === 'number') opts.efSearch = input.efSearch;\n      const mem = await openWithLineage(api, path);\n      try {\n        const hits = await mem.query(vector, k, opts);\n        return { success: true, path, k, hits };\n      } finally {\n        await mem.close?.();\n      }\n    },\n  },\n  {\n    name: 'agenticow_diff',\n    description: 'agenticow — show what a branch changed relative to its lineage: {added, overridden, deleted} vector-id lists. Use when you are about to promote and want to preview the exact merge, or when auditing what a branch actually wrote. Diffing by re-querying is wrong because deletions (tombstones) are invisible to a read — diff() surfaces them explicitly. Requires the branch was opened with edit tracking (default on).',\n    category: 'memory',\n    tags: ['agenticow', 'memory', 'cow', 'diff'],","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts#L154-L190","documentation":"Thrown by the agenticow_query handler (agenticow-tools.ts:172) when the vector argument is not a non-empty array. HNSW nearest-neighbor search needs a query vector with the same dimension as the store, so an empty, missing, or non-array vector is rejected before the memory file is even opened.","triggerScenarios":"Calling agenticow_query with vector omitted, vector: [], vector as a string ('[0.1, 0.2]'), or a nested wrapper ({values: [...]}). The check is Array.isArray(vector) && vector.length > 0.","commonSituations":"Reusing an embedding variable that came back undefined from a failed API call; double-stringified JSON vectors; query built from a search box without an embedding step; dimension mismatch with the file (passes this check, fails later).","solutions":["Compute the query embedding first and pass a flat number[] with the store's dimension","Parse/guard the vector right before the call: Array.isArray(v) && v.length === dim","Fail loudly if the embedding service returned nothing instead of forwarding undefined"],"exampleFix":"// before\nawait callTool('agenticow_query', { path: p, vector: undefined, k: 10 });\n// throws: vector must be a non-empty numeric array\n\n// after\nconst q = await embed(userQuery);\nif (!Array.isArray(q) || q.length !== 384) throw new Error('embedding failed');\nawait callTool('agenticow_query', { path: p, vector: q, k: 10 });","handlingStrategy":"validation","validationCode":"function isNumericVector(v: unknown): v is number[] {\n  return Array.isArray(v) && v.length > 0 && v.every((n) => typeof n === 'number' && Number.isFinite(n));\n}\nif (!isNumericVector(queryVector)) throw new TypeError('embedding step failed — no query vector');","typeGuard":"function isNumericVector(v: unknown): v is number[] {\n  return Array.isArray(v) && v.length > 0 && v.every((n) => typeof n === 'number' && Number.isFinite(n));\n}","tryCatchPattern":null,"preventionTips":["Fail loudly when the embedding service returns undefined/null instead of forwarding it","Check vector length matches the store dimension before querying"],"tags":["validation","agenticow","vectors","embeddings","mcp"],"backgroundTag":"invalid-vector-format","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}