{"record":{"id":"d23d27470c2fd2d9","repo":"rohitg00/agentmemory","slug":"memoryids-is-required","errorCode":null,"errorMessage":"memoryIds is required","messagePattern":"memoryIds is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mcp/standalone.ts","lineNumber":171,"sourceCode":"      if (typeof fmt === \"string\" && fmt.trim()) {\n        v.format = fmt.trim().toLowerCase();\n      }\n      const budget = args[\"token_budget\"];\n      if (typeof budget === \"number\" && Number.isFinite(budget) && budget > 0) {\n        v.tokenBudget = Math.floor(budget);\n      } else if (typeof budget === \"string\" && budget.trim()) {\n        const n = Number(budget);\n        if (Number.isFinite(n) && n > 0) v.tokenBudget = Math.floor(n);\n      }\n      return v;\n    }\n    case \"memory_sessions\": {\n      v.limit = parseLimit(args[\"limit\"], 20);\n      return v;\n    }\n    case \"memory_governance_delete\": {\n      const ids = normalizeList(args[\"memoryIds\"]);\n      if (ids.length === 0) throw new Error(\"memoryIds is required\");\n      v.memoryIds = ids;\n      v.reason = (args[\"reason\"] as string) || \"plugin skill request\";\n      return v;\n    }\n    case \"memory_export\":\n      return v;\n    case \"memory_audit\": {\n      v.limit = parseLimit(args[\"limit\"], 50);\n      return v;\n    }\n    default:\n      throw new Error(`Unknown tool: ${toolName}`);\n  }\n}\n\nasync function handleProxy(\n  v: Validated,\n  handle: ProxyHandle,","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/rohitg00/agentmemory/blob/e04ba88819c365c9acf9d6661ea802143e728bd6/src/mcp/standalone.ts#L153-L189","documentation":"The memory_governance_delete tool requires a memoryIds argument that normalizes (via normalizeList, which accepts a comma-separated string or array) to a non-empty list of ids. An empty or absent memoryIds throws this error, protecting against accidental mass/unbounded deletes.","triggerScenarios":"Calling memory_governance_delete with no memoryIds key, an empty array [], an empty string \"\", or a string of only commas/whitespace such that normalizeList yields zero entries.","commonSituations":"Scripts that collected ids from a prior search which returned nothing; LLM agents deleting 'everything' by omitting the field; CSV input that was blank.","solutions":["Pass a non-empty array of ids: memoryIds: [\"id1\", \"id2\"] or a CSV string \"id1,id2\".","Verify the preceding search/list step actually returned ids before chaining a delete.","If a bulk delete of many memories is intended, enumerate the ids explicitly — never call with an empty list."],"exampleFix":"// before\nawait callTool(\"memory_governance_delete\", { memoryIds: ids }); // ids = []\n// after\nif (ids.length === 0) throw new Error(\"nothing to delete\");\nawait callTool(\"memory_governance_delete\", { memoryIds: ids, reason: \"cleanup\" });","handlingStrategy":"validation","validationCode":"function toIds(v) {\n  const ids = Array.isArray(v) ? v : typeof v === \"string\" ? v.split(\",\") : [];\n  return ids.map((s) => String(s).trim()).filter(Boolean);\n}\nif (toIds(args.memoryIds).length === 0) throw new Error(\"governance_delete needs at least one id\");","typeGuard":"function hasMemoryIds(args: Record<string, unknown>): args is { memoryIds: string[] } & Record<string, unknown> {\n  const v = args.memoryIds;\n  if (Array.isArray(v)) return v.length > 0 && v.every((x) => typeof x === \"string\");\n  return typeof v === \"string\" && v.split(\",\").some((s) => s.trim());\n}","tryCatchPattern":"try {\n  return await callTool(\"memory_governance_delete\", args);\n} catch (e) {\n  if (e.message === \"memoryIds is required\") {\n    throw new Error(\"delete aborted: no ids resolved from prior search — nothing to delete\");\n  }\n  throw e;\n}","preventionTips":["Check the count of results from the preceding search before chaining a delete.","Always pass an explicit non-empty id list; never let empty arrays through.","Require a reason string for auditability on every governance delete."],"tags":["mcp","validation","governance"],"backgroundTag":"missing-required-argument","analyzedSha":"e04ba88819c365c9acf9d6661ea802143e728bd6","analyzedAt":"2026-08-30T01:07:40.754Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}