{"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":"validation","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/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts#L154-L190","documentation":"Thrown by the agenticow_query MCP tool handler when the `vector` argument is not a non-empty array. The query performs a k-nearest-neighbour search against an .rvf memory file, so a valid query vector is the one mandatory input (path and vector are both required). The guard runs before the lineage store is opened.","triggerScenarios":"Calling agenticow_query with vector omitted, null, a non-array, or an empty array []. Even though the JSON schema requires vector, direct handler callers bypass schema validation.","commonSituations":"Passing a single number instead of an array; an embedding model returning null on failure; a serialised vector string that was never parsed; a typed array that fails Array.isArray.","solutions":["Pass vector as a non-empty numeric array whose length equals the store dimension.","Wrap embedding generation in a null/empty check before querying.","Convert Float32Array/Float64Array via Array.from(...) — they fail Array.isArray.","Verify the embedding pipeline returned a dense vector, not a sparse object representation."],"exampleFix":"// before\nagenticow_query({ path, vector: embedding })\n// after\nconst v = Array.isArray(embedding) ? embedding : Array.from(embedding)\nif (!v || v.length === 0) throw new Error('empty embedding')\nagenticow_query({ path, vector: v })","handlingStrategy":"validation","validationCode":"function validateQueryVector(vector) {\n  const v = Array.isArray(vector) ? vector : Array.from(vector ?? []);\n  if (!v || v.length === 0) throw new Error('query vector must be a non-empty array');\n  if (!v.every((n) => typeof n === 'number' && Number.isFinite(n))) throw new Error('query vector must be all finite numbers');\n  return v;\n}","typeGuard":"function isQueryVector(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":["Guard embedding generation against null/empty returns before querying.","Coerce typed arrays to plain arrays at the boundary.","Confirm the vector length matches the store dimension."],"tags":["agenticow","mcp-tools","validation","vector-search","query"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}