{"record":{"id":"e0b2832cce0e5df2","repo":"affaan-m/ECC","slug":"at-least-one-target-is-required-for-handoffs","errorCode":null,"errorMessage":"At least one --target is required for handoffs.","messagePattern":"At least one --target is required for handoffs\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/memory.js","lineNumber":419,"sourceCode":"  }\n}\n\nfunction runInitCommand({ command, options, positionals, roots }) {\n  requireNoPositionals(positionals, command);\n  return printInit(\n    initializeVault({ roots, scopes: options.scopes || undefined }),\n    options.json\n  );\n}\n\nfunction runWriteCommand({ command, options, positionals, roots }) {\n  requireNoPositionals(positionals, command);\n  if (!options.title) throw new Error('--title is required.');\n  if (command === 'handoff' && !options.from) {\n    throw new Error('--from is required for handoffs.');\n  }\n  if (command === 'handoff' && (!options.targets || options.targets.length === 0)) {\n    throw new Error('At least one --target is required for handoffs.');\n  }\n  return printWrite(\n    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","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory.js#L401-L437","documentation":"A handoff must declare at least one destination. runWriteCommand throws 'At least one --target is required for handoffs.' when options.targets is missing or an empty array for handoff commands. Targets tell the memory vault which agents/tasks the handoff is addressed to.","triggerScenarios":"Running `memory handoff` with --title and --from but no --target flags (or a wrapper collecting zero targets into an empty list). Raised in runWriteCommand after the --from check.","commonSituations":"Building the command dynamically from a targets list that ended up empty; typo-ing the flag (--targets vs repeated --target) so parsing yields no targets; template scripts where the recipient step was removed.","solutions":["Add at least one `--target <name>` flag to the handoff invocation (repeat the flag for multiple targets).","Verify the flag name/spelling matches what the parser expects (`--target`, repeated per recipient).","In scripts, guard the list: `[ ${#TARGETS[@]} -gt 0 ] || { echo 'need a target'; exit 1; }` before building the command.","If no recipient is known yet, defer the handoff or save as a regular note instead."],"exampleFix":"// before\nnode scripts/memory.js handoff --title \"ctx\" --from claude --body-file ctx.md\n// after\nnode scripts/memory.js handoff --title \"ctx\" --from claude --target codex --body-file ctx.md","handlingStrategy":"validation","validationCode":"if (command === 'handoff' && (!Array.isArray(opts.targets) || opts.targets.length === 0)) {\n  throw new Error('handoff requires at least one --target.');\n}","typeGuard":"const hasTargets = (o) => Array.isArray(o?.targets) && o.targets.length > 0;","tryCatchPattern":"try {\n  runWriteCommand(args);\n} catch (err) {\n  if (err.message === 'At least one --target is required for handoffs.') {\n    console.error('Add one or more --target <name> flags to the handoff.');\n  } else throw err;\n}","preventionTips":["Validate the recipient list length before composing the command string.","Emit one --target flag per recipient; do not rely on a single --targets list flag.","Fall back to a regular save if no recipient is determined yet."],"tags":["cli","missing-argument","handoff"],"backgroundTag":"missing-required-flag","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"}