{"record":{"id":"91a4c3cb994fa623","repo":"ruvnet/ruflo","slug":"records-must-be-a-non-empty-array-of-id-vector","errorCode":null,"errorMessage":"records must be a non-empty array of {id?, vector, text?}","messagePattern":"records must be a non-empty array of (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts","lineNumber":128,"sourceCode":"              id: { type: 'integer', description: 'Explicit id (auto-assigned when omitted)' },\n              vector: { type: 'array', items: { type: 'number' }, description: 'Embedding vector (length must equal the memory dimension)' },\n              text: { type: 'string', description: 'Optional payload surfaced on query hits' },\n            },\n            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?.();","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/mcp-tools/agenticow-tools.ts#L110-L146","documentation":"Thrown by the agenticow_ingest MCP tool handler when the `records` argument is not a non-empty array. Ingest is the write half that populates a branch or base with vectors, so at least one record shaped {id?, vector, text?} must be present. The guard runs before any lineage file is opened.","triggerScenarios":"Calling agenticow_ingest with records omitted, null, a non-array value (object/string), or an empty array []. The JSON schema marks records as required, but runtime callers bypassing the schema still hit this.","commonSituations":"Passing records as a single object instead of an array; an upstream filter producing zero records; deserialisation yielding undefined when the field was absent.","solutions":["Pass records as an array with at least one element: [{ vector: [0.1, ...] }].","If your batch is empty, skip the ingest call entirely rather than invoking with [].","Guard the call site with Array.isArray(records) && records.length > 0 before invoking.","Confirm each element is an object with a vector field (the next check, error 243, enforces that)."],"exampleFix":"// before\nagenticow_ingest({ path, records: record })\n// after\nagenticow_ingest({ path, records: [record] })","handlingStrategy":"validation","validationCode":"function validateIngestRecords(records) {\n  if (!Array.isArray(records) || records.length === 0) {\n    throw new Error('records must be a non-empty array');\n  }\n  return records;\n}","typeGuard":"function isIngestRecordArray(v: unknown): v is Array<{ vector: number[] }> {\n  return Array.isArray(v) && v.length > 0 && v.every((r) => r && typeof r === 'object' && Array.isArray((r as any).vector));\n}","tryCatchPattern":null,"preventionTips":["Wrap a single record in an array literal at the call site.","Skip the ingest call when the batch is empty rather than invoking with [].","Type the parameter as Array<...> so the compiler rejects a bare object."],"tags":["agenticow","mcp-tools","validation","ingest","input-validation"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}