{"record":{"id":"69b6d03db9508470","repo":"ruvnet/ruflo","slug":"each-record-requires-a-non-empty-numeric-vector","errorCode":null,"errorMessage":"each record requires a non-empty numeric vector","messagePattern":"each record requires a non-empty numeric vector","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts","lineNumber":132,"sourceCode":"            required: ['vector'],\n          },\n        },\n        dimension: { type: 'integer', description: 'Vector dimension (required only when path does not exist yet)' },\n      },\n      required: ['path', 'records'],\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 records = input.records as Array<{ id?: number; vector: number[]; text?: string }>;\n      if (!Array.isArray(records) || records.length === 0) {\n        throw new Error('records must be a non-empty array of {id?, vector, text?}');\n      }\n      for (const r of records) {\n        if (!Array.isArray(r.vector) || r.vector.length === 0) {\n          throw new Error('each record requires a non-empty numeric vector');\n        }\n      }\n      const dim = (input.dimension as number | undefined) ?? records[0].vector.length;\n      const mem = await openWithLineage(api, path, dim);\n      try {\n        const result = await mem.ingest(records.map((r) => ({\n          ...(typeof r.id === 'number' ? { id: r.id } : {}),\n          vector: r.vector,\n          ...(r.text !== undefined ? { text: r.text } : {}),\n        })));\n        await mem.save?.(manifestFor(path));\n        return { success: true, path, ingested: result };\n      } finally {\n        await mem.close?.();\n      }\n    },\n  },\n  {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts#L114-L150","documentation":"Thrown by agenticow_ingest while iterating records: every record must carry a `vector` that is a non-empty array. Vectors are the embedding payloads indexed by the HNSW store; a missing or empty vector cannot be ingested and would corrupt dimension tracking, so the tool rejects it up front.","triggerScenarios":"Any record in the records array whose `vector` is undefined, not an array, or an empty array []. The loop validates each record before opening lineage and before deriving the default dimension from records[0].vector.length.","commonSituations":"Mixing record shapes where some omit vector; passing text-only payloads; an embedding step that returned [] for a short input; serialising Float32Array which is array-like but fails Array.isArray.","solutions":["Ensure every record has vector: number[] with length > 0 matching the memory dimension.","Convert typed arrays (Float32Array/Float64Array) via Array.from(...) before passing.","Filter out malformed records upstream so the ingest batch is uniform.","If dimension is unset, confirm records[0].vector.length is the intended dimension."],"exampleFix":"// before\n{ id: 1, text: 'hello' }\n// after\n{ id: 1, vector: Array.from(embedding), text: 'hello' }","handlingStrategy":"validation","validationCode":"function normalizeRecords(records) {\n  return records.map((r) => {\n    const vector = Array.isArray(r.vector) ? r.vector : Array.from(r.vector ?? []);\n    if (vector.length === 0) throw new Error(`record ${r.id ?? '?'} has empty vector`);\n    return { ...r, vector };\n  });\n}","typeGuard":"function isNonEmptyNumberArray(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":["Convert typed arrays (Float32Array) via Array.from before passing.","Treat empty embeddings from the model as a hard error, not a skip.","Keep record shapes uniform across the batch."],"tags":["agenticow","mcp-tools","validation","vector","ingest"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}