{"record":{"id":"2d241be054c636d2","repo":"Hmbown/CodeWhale","slug":"worktree-repo-and-branch-must-be-provided-toge","errorCode":null,"errorMessage":"--worktree-repo and --branch must be provided together","messagePattern":"--worktree-repo and --branch must be provided together","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/lib.rs","lineNumber":776,"sourceCode":"        environment,\n        cwd,\n    } = request;\n    let kind = RuntimeBackendKind::parse(&runtime)?;\n    let reg = LaneRegistry::open_default()?;\n    let mut record = reg.create_pending(workflow, fleet, issue, goal, kind, worktree_ttl_secs)?;\n    let worktree = match (worktree_repo, branch) {\n        (Some(repo_root), Some(branch_name)) => {\n            let path = worktree_path\n                .unwrap_or_else(|| repo_root.join(\".codewhale\").join(\"lanes\").join(&record.id));\n            Some(WorktreeProvision {\n                repo_root,\n                branch: branch_name,\n                path,\n                base_ref: None,\n            })\n        }\n        (None, None) => None,\n        _ => bail!(\"--worktree-repo and --branch must be provided together\"),\n    };\n    let cmd = if command.is_empty() {\n        vec![\n            \"sh\".into(),\n            \"-c\".into(),\n            format!(\"echo lane {} started\", record.id),\n        ]\n    } else {\n        command\n    };\n    let spec = LaneStartSpec {\n        command: cmd,\n        cwd,\n        environment,\n        log_proxy: (kind == RuntimeBackendKind::Tmux)\n            .then(std::env::current_exe)\n            .transpose()\n            .context(\"resolve current Codewhale executable for tmux log proxy\")?,","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/cli/src/lib.rs#L758-L794","documentation":"When starting a lane with a provisioned git worktree, the CLI requires --worktree-repo and --branch as a pair: the worktree path is derived as <repo>/.codewhale/lanes/<lane-id> when --worktree-path is absent. This bail fires when exactly one of the two flags is given, because a worktree cannot be created from a repo without a branch or vice versa.","triggerScenarios":"`codewhale lane start --worktree-repo /src/app` (missing --branch) or `codewhale lane start --branch feat/x` (missing --worktree-repo); shell scripts where one variable expanded empty so only one flag survived.","commonSituations":"Scripted lane startup with an unset BRANCH or REPO variable; copying a partial command from docs; wrapping the flag pair conditionally (e.g. ${BRANCH:+--branch $BRANCH}) without the matching pair.","solutions":["Pass both flags together: codewhale lane start --worktree-repo /src/app --branch feat/lane-1","Or omit both to start the lane without a worktree","In scripts, guard the pair: if [ -n \"$REPO\" ] && [ -n \"$BRANCH\" ]; then set -- --worktree-repo \"$REPO\" --branch \"$BRANCH\"; fi","Use set -u so an unset variable fails loudly instead of silently dropping one flag"],"exampleFix":"# before\ncodewhale lane start --runtime tmux --worktree-repo /src/app\n# after\ncodewhale lane start --runtime tmux --worktree-repo /src/app --branch feat/lane-1","handlingStrategy":"validation","validationCode":"fn lane_flags_ok(worktree_repo: &Option<PathBuf>, branch: &Option<String>) -> bool {\n    matches!((worktree_repo, branch), (Some(_), Some(_)) | (None, None))\n}","typeGuard":"fn worktree_flags_paired(repo: Option<&str>, branch: Option<&str>) -> bool {\n    matches!((repo, branch), (Some(_), Some(_)) | (None, None))\n}","tryCatchPattern":null,"preventionTips":["Set flags as an inseparable pair in scripts; guard with if [ -n \"$REPO\" ] && [ -n \"$BRANCH\" ]","Use set -u so unset variables fail before emitting half a pair","Encapsulate lane start in one wrapper function that takes both or neither"],"tags":["cli","lane","worktree","arguments","validation"],"backgroundTag":"dependent-cli-flags-missing","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}