{"record":{"id":"70763d7abe669d60","repo":"gitbutlerapp/gitbutler","slug":"expected-a-branch-id-got","errorCode":null,"errorMessage":"Expected a branch ID, got {}","messagePattern":"Expected a branch ID, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/land/mod.rs","lineNumber":53,"sourceCode":"                bail!(\n                    \"`but land` requires an active GitButler workspace (`gitbutler/workspace`). \\\n                     Switch into the workspace and try again.\"\n                );\n            }\n        }\n\n        let id_map = IdMap::new_from_context(ctx, guard.read_permission())?;\n        let resolved_ids = id_map.parse_using_context(branch_id, ctx)?;\n        if resolved_ids.is_empty() {\n            bail!(\"Could not find branch: {branch_id}\");\n        }\n        if resolved_ids.len() > 1 {\n            bail!(\"Ambiguous branch '{branch_id}', matches multiple items\");\n        }\n\n        let branch_name = match &resolved_ids[0] {\n            CliId::Branch(branch) => branch.name.clone(),\n            other => bail!(\"Expected a branch ID, got {}\", other.kind_for_humans()),\n        };\n\n        let base_branch =\n            but_api::legacy::virtual_branches::get_base_branch_data(ctx, guard.write_permission())?\n                .ok_or_else(|| anyhow::anyhow!(\"No base branch configured\"))?;\n        (branch_name, base_branch)\n    };\n\n    // Display strings for the prompt and the final report. The API recomputes the target/remote\n    // configuration internally; the CLI only needs these names to describe what's about to happen.\n    let target_branch_name = base_branch.short_name.clone();\n    let push_remote_name = if base_branch.push_remote_name.is_empty() {\n        base_branch.remote_name.clone()\n    } else {\n        base_branch.push_remote_name.clone()\n    };\n    let target_display = format!(\"{push_remote_name}/{target_branch_name}\");\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/land/mod.rs#L35-L71","documentation":"The branch ID given to `but land` resolved uniquely — but to the wrong kind of entity, reported via `kind_for_humans()` (a commit or an uncommitted file instead of a `CliId::Branch`). Land operates on lanes/branches only, so the handler bails naming what it actually got.","triggerScenarios":"`but land <commit-id>` or `but land <uncommitted-file-id>` — IDs that resolve fine, just not to a branch (land/mod.rs:52-54).","commonSituations":"Grabbing a commit's ID from `but status` output instead of its lane's; muscle memory from commands that do accept commits (e.g. `but resolve <commit>`).","solutions":["Use the lane/branch ID shown in the branches section of `but status`.","Pass the plain branch name instead of an ID.","If you meant to act on a commit, use a commit-oriented command (e.g. `but resolve <commit>`), not `but land`."],"exampleFix":"# before\nbut land 4z --yes   # 4z is a commit ID -> Expected a branch ID, got commit\n\n# after\nbut land b2 --yes   # b2 is the lane that contains commit 4z","handlingStrategy":"type-guard","validationCode":"# Use lane IDs/names only; verify the ID appears in the branches section of `but status`\nbut status | grep -F '<id>'","typeGuard":"// Narrow before acting: land accepts only branches\nmatch &resolved_ids[0] {\n    CliId::Branch(branch) => { /* safe to land `branch.name` */ }\n    other => { /* reject: expected a branch, got `other.kind_for_humans()` */ }\n}","tryCatchPattern":null,"preventionTips":["Check which section of `but status` an ID comes from before passing it to a branch-scoped command.","Remember the split: `land` takes branches; `resolve`/`squash` take commits."],"tags":["cli","id-resolution","type-mismatch","land","gitbutler"],"backgroundTag":"wrong-entity-type-for-id","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}