{"record":{"id":"58c2846af74d0afe","repo":"nexu-io/open-design","slug":"target-reuse-needs-project-id","errorCode":null,"errorMessage":"--target reuse needs --project <id>","messagePattern":"--target reuse needs --project <id>","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/cli.ts","lineNumber":10558,"sourceCode":"\nfunction parseAutomationTarget(flags) {\n  const raw = flags.target;\n  if (raw == null) {\n    if (flags.project) return { mode: 'reuse', projectId: String(flags.project) };\n    return { mode: 'create_each_run' };\n  }\n  const value = String(raw);\n  if (\n    value === 'worktree' ||\n    value === 'new-project' ||\n    value === 'create-each-run' ||\n    value === 'create_each_run'\n  ) {\n    return { mode: 'create_each_run' };\n  }\n  if (value === 'reuse') {\n    if (!flags.project) {\n      throw new Error('--target reuse needs --project <id>');\n    }\n    return { mode: 'reuse', projectId: String(flags.project) };\n  }\n  const eq = value.indexOf('=');\n  if ((value.startsWith('reuse=') || value.startsWith('reuse:')) && eq > 0) {\n    const projectId = value.slice(eq + 1).trim();\n    if (!projectId) throw new Error('--target reuse=<projectId> needs a non-empty id');\n    return { mode: 'reuse', projectId };\n  }\n  throw new Error(\n    `--target must be \"new-project\" or \"reuse=<projectId>\" (got \"${value}\")`,\n  );\n}\n\nfunction describeAutomationScheduleForCli(schedule) {\n  if (!schedule) return '-';\n  if (schedule.kind === 'hourly') {\n    return `hourly:${String(schedule.minute).padStart(2, '0')}`;","sourceCodeStart":10540,"sourceCodeEnd":10576,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/cli.ts#L10540-L10576","documentation":"Thrown by parseAutomationTarget when `--target reuse` is given but no `--project <id>` flag accompanies it. The `reuse` mode requires a target project id to reuse; without one the parser cannot form a valid reuse target. Note the bare word `reuse` (not `reuse=...`) specifically depends on the separate `--project` flag.","triggerScenarios":"Running `od automation create --target reuse` without also passing `--project <id>`, or passing `--project` with an empty value.","commonSituations":"Confusing the two reuse forms: `--target reuse` (needs `--project`) versus `--target reuse=<id>` (carries the id inline). Forgetting the project id when scripting.","solutions":["Add the project id: `--target reuse --project <projectId>`.","Or switch to the inline form: `--target reuse=<projectId>`.","Verify the project id is non-empty and is a project you can access."],"exampleFix":"// before\nod automation create --target reuse\n// after\nod automation create --target reuse=proj_123\n// or\nod automation create --target reuse --project proj_123","handlingStrategy":"validation","validationCode":"// Before calling parseAutomationTarget, ensure 'reuse' carries a project id.\nfunction reuseTargetIsComplete(flags: { target?: unknown; project?: unknown }): boolean {\n  if (flags.target !== 'reuse') return true;\n  return Boolean(flags.project && String(flags.project).trim());\n}","typeGuard":null,"tryCatchPattern":"try {\n  parseAutomationTarget(flags);\n} catch (err) {\n  if (err instanceof Error && /--target reuse needs --project/.test(err.message)) {\n    // prompt for a project id, or fall back to create-each-run\n  }\n  throw err;\n}","preventionTips":["Prefer the inline `reuse=<projectId>` form to keep the id next to the mode.","When scripting, default to omitting --target (create-each-run) unless reuse is intentional."],"tags":["cli","validation","automation","flag-parsing"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}