{"record":{"id":"fc8a68450696b267","repo":"gitbutlerapp/gitbutler","slug":"could-not-find-branch-branch-id","errorCode":null,"errorMessage":"Could not find branch: {branch_id}","messagePattern":"Could not find branch: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/land/mod.rs","lineNumber":45,"sourceCode":"    // runs here for a friendly message before the prompt; the API enforces it again, along with the\n    // bottom-segment, conflicted-commit, and triangular-remote guards, before mutating anything.\n    let (branch_name, base_branch) = {\n        let mut guard = ctx.exclusive_worktree_access();\n\n        {\n            let (_repo, ws, _db) = ctx.workspace_and_db_with_perm(guard.read_permission())?;\n            if !ws.kind.has_managed_ref() {\n                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.","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/land/mod.rs#L27-L63","documentation":"`but land <id>` resolves the identifier through the per-workspace IdMap (land/mod.rs:42-46). An empty result set means the ID matches nothing known in this workspace — typo, stale short ID, or wrong project — and the handler bails before reading configuration or touching anything.","triggerScenarios":"`but land <id>` where `IdMap::parse_using_context` returns no entries: typo'd prefixes, IDs copied from another workspace or an older `but status`, or IDs invalidated by rebase/squash operations that rebuilt the map.","commonSituations":"Short IDs going stale after the workspace rewrites history; switching between multiple GitButler projects; fat-fingering the copied ID.","solutions":["Run `but status` in the same directory and re-copy the branch ID.","Use the branch's full name instead of a short ID.","Confirm you are in the right repo/project before retrying."],"exampleFix":"# before\nbut land b7      # stale/typo'd ID -> Could not find branch: b7\n\n# after\nbut status       # copy the current lane ID or name\nbut land <fresh-id> --yes","handlingStrategy":"validation","validationCode":"# Resolve first: the ID must appear in this workspace's status\nbut status | grep -F '<id>' || { echo 'unknown branch id'; exit 2; }\nbut land '<id>' --yes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Re-run `but status` right before using short IDs; they change as the workspace evolves.","Prefer full branch names in scripts for stability."],"tags":["cli","id-resolution","land","gitbutler"],"backgroundTag":"entity-not-found-by-id","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}