{"record":{"id":"6092b93aabf57078","repo":"affaan-m/ECC","slug":"read-requires-exactly-one-memory-id","errorCode":null,"errorMessage":"read requires exactly one memory ID.","messagePattern":"read requires exactly one memory ID\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/memory.js","lineNumber":440,"sourceCode":"    saveMemory(saveInput(options, command === 'handoff' ? 'handoff' : null), { roots }),\n    options.json\n  );\n}\n\nfunction runSearchCommand({ options, positionals, roots }) {\n  const query = positionals.join(' ');\n  return printSearch(query, searchMemories(query, {\n    roots,\n    scopes: options.scopes,\n    kinds: options.kinds,\n    targetHarness: options.targetHarness,\n    limit: options.limit,\n  }), options.json);\n}\n\nfunction runReadCommand({ options, positionals, roots }) {\n  if (positionals.length !== 1) {\n    throw new Error('read requires exactly one memory ID.');\n  }\n  return printRead(readMemoryById(positionals[0], {\n    roots,\n    scopes: options.scopes,\n  }), options.json);\n}\n\nfunction runDoctorCommand({ command, options, positionals, roots }) {\n  requireNoPositionals(positionals, command);\n  return printDoctor(doctorMemoryVault({\n    roots,\n    scopes: options.scopes,\n  }), options.json);\n}\n\nconst COMMAND_HANDLERS = Object.freeze({\n  doctor: runDoctorCommand,\n  handoff: runWriteCommand,","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory.js#L422-L458","documentation":"runReadCommand reads a single memory entry by its ID, so it requires exactly one positional argument. It throws 'read requires exactly one memory ID.' when positionals.length !== 1 — zero IDs, or multiple IDs passed at once, both fail. IDs are not accepted via flags here; they must be positionals.","triggerScenarios":"Running `memory read` with no ID, with two or more IDs (`memory read id1 id2`), or putting the ID after a flag in a way the parser treats as a positional count mismatch. Raised at the top of runReadCommand.","commonSituations":"Assuming read accepts a list of IDs (batch reads are unsupported); losing the ID because a variable was empty (`memory read \"$MEM_ID\"` with unset MEM_ID); pasting an ID containing whitespace so it splits into two positionals.","solutions":["Pass exactly one memory ID as a single positional: `node scripts/memory.js read <id>`.","Quote the ID variable: `memory read \"$MEM_ID\"` to prevent whitespace splitting; check it is non-empty first.","For multiple entries, loop over IDs invoking read once per ID (or use a list/search command if available).","Capture the ID from save output (printWrite with --json) instead of hand-copying, to avoid malformed IDs."],"exampleFix":"// before\nnode scripts/memory.js read mem_001 mem_002\n// after\nnode scripts/memory.js read mem_001\nnode scripts/memory.js read mem_002","handlingStrategy":"validation","validationCode":"const ids = positionals.filter((p) => typeof p === 'string' && p.trim() !== '');\nif (ids.length !== 1) throw new Error('memory read takes exactly one quoted memory ID.');","typeGuard":"const isSingleId = (args) => args.length === 1 && typeof args[0] === 'string' && args[0].trim() !== '';","tryCatchPattern":"try {\n  runReadCommand(args);\n} catch (err) {\n  if (err.message === 'read requires exactly one memory ID.') {\n    console.error('Usage: memory read <id> — one ID per invocation; loop for batches.');\n  } else throw err;\n}","preventionTips":["Always quote ID variables: memory read \"$MEM_ID\".","Check IDs are non-empty before invoking; capture IDs from save --json output.","Batch reads with a shell loop, one read per ID."],"tags":["cli","argument-count","read"],"backgroundTag":"missing-required-argument","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}