{"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":"exception","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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/memory.js#L401-L437","documentation":"Thrown by runWriteCommand in scripts/memory.js when the `handoff` subcommand is called with no `--target` values. Handoffs are addressed to one or more target harnesses, so an empty target list is rejected before writing. This is checked after the `--from` guard, so a handoff missing both flags fails on `--from` first.","triggerScenarios":"Running `node scripts/memory.js handoff --from claude --title \"X\"` with no `--target`. Passing `--target` with no following value, or an options.targets array that is undefined or zero-length. Note the defaulting in saveInput (`options.targets || ['all']`) only applies to the `save` command path, not this handoff guard.","commonSituations":"Assuming handoffs default to all harnesses (they do not — only `save` does); a wrapper script that conditionally appends `--target` and skips it when the list is empty; copy-pasting a `save` invocation and changing the verb to `handoff` without adding target flags.","solutions":["Add at least one `--target <harness>` (e.g. `--target claude --target cursor`) to the handoff.","If you want the 'address all harnesses' behavior, use the `save` subcommand instead of `handoff`.","In scripts, fail fast if the computed target list is empty rather than letting the CLI reject it."],"exampleFix":"// before\nnode scripts/memory.js handoff --from claude --title \"Hand off work\"\n// after\nnode scripts/memory.js handoff --from claude --target cursor --title \"Hand off work\"","handlingStrategy":"validation","validationCode":"function buildTargets(targets) {\n  const list = (Array.isArray(targets) ? targets : [targets]).filter(t => typeof t === 'string' && t.length > 0);\n  if (list.length === 0) throw new Error('handoff needs at least one non-empty --target');\n  return list.flatMap(t => ['--target', t]);\n}","typeGuard":"function hasTargets(value) {\n  return Array.isArray(value) && value.length > 0 && value.every(t => typeof t === 'string' && t.length > 0);\n}","tryCatchPattern":null,"preventionTips":["Default to the `save` command only if 'all harnesses' is truly intended; otherwise require explicit targets.","Filter empty strings out of target lists before invoking the CLI so a stray empty does not silently pass the array-length check.","Unit-test the argument builder against the empty-list edge case."],"tags":["cli","memory","argument-validation","handoff"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}