{"record":{"id":"29f9074580e42a9a","repo":"gitbutlerapp/gitbutler","slug":"branch-not-found-branch-name","errorCode":null,"errorMessage":"Branch not found: {branch_name}","messagePattern":"Branch not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/legacy/absorb.rs","lineNumber":145,"sourceCode":"            let all_assignments = worktree_changes.assignments;\n            let dependencies = worktree_changes.dependencies;\n\n            // Get the stack ID for this branch\n            let workspace = crate::legacy::workspace::head_info(ctx)?;\n\n            // Find the stack that contains this branch\n            let stack = workspace\n                .stacks\n                .iter()\n                .find(|stack| {\n                    stack.segments.iter().any(|segment| {\n                        segment\n                            .ref_info\n                            .as_ref()\n                            .is_some_and(|ri| ri.ref_name.shorten() == branch_name.as_bytes())\n                    })\n                })\n                .ok_or_else(|| anyhow::anyhow!(\"Branch not found: {branch_name}\"))?;\n\n            let stack_id = stack.id.ok_or_else(|| anyhow::anyhow!(\"Stack has no ID\"))?;\n\n            // Filter assignments to just this stack\n            let candidates: Vec<AbsorbCandidate> = all_assignments\n                .into_iter()\n                .filter(|a| a.stack_id == Some(stack_id))\n                .map(Into::into)\n                .collect();\n\n            if candidates.is_empty() {\n                anyhow::bail!(\"No uncommitted changes assigned to branch: {branch_name}\");\n            }\n\n            (candidates, dependencies)\n        }\n        AbsorptionTarget::TreeChanges {\n            changes,","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/legacy/absorb.rs#L127-L163","documentation":"`absorption_plan_with_perm` computes an absorb plan from workspace stacks/assignments, filtering for the stack whose applied segment's shortened ref name equals `branch_name`. If no stack's segment matches, it throws \"Branch not found: {branch_name}\". It means the requested branch is not an applied segment in the current workspace.","triggerScenarios":"Calling the absorption_plan API with a branch name that is not the shortened ref name of any applied stack segment — branch unapplied, branch name given with a prefix (e.g. `refs/heads/` or `origin/`), or the branch exists but has no matching `ref_info` segment.","commonSituations":"Absorbing into a branch that was unapplied from the workspace; passing a remote-tracking name instead of the local name; case or slash mismatches in the branch name; running before any commits exist on the stack segment.","solutions":["List applied workspace branches (`but branch list`) and use the exact short name shown.","Strip any `refs/heads/` prefix and remote prefixes from the branch name before calling.","Apply the stack to the workspace first if it is unapplied.","Verify the branch belongs to the workspace you are querying, not another worktree."],"exampleFix":"// before\nabsorption_plan(repo, \"refs/heads/feature\")?;\n// after\nabsorption_plan(repo, \"feature\")?; // exact short branch name of an applied stack","handlingStrategy":"validation","validationCode":"// verify the branch is an applied stack segment before planning absorb\nlet ws = ctx.workspace()?;\nlet applied = ws.stacks.iter().any(|s|\n    s.segments.iter().any(|seg|\n        seg.ref_info.as_ref().is_some_and(|ri| ri.ref_name.shorten() == branch.as_bytes())));\nif !applied { return Err(anyhow::anyhow!(\"{branch} is not an applied workspace branch\")); }","typeGuard":null,"tryCatchPattern":"match absorption_plan(ctx, branch) {\n    Err(e) if e.to_string().starts_with(\"Branch not found:\") =>\n        eprintln!(\"apply the branch to the workspace first\"),\n    other => other?,\n}","preventionTips":["Use short branch names exactly as shown by workspace listing (no refs/heads/ prefix)","Only absorb into branches currently applied in the workspace","Refresh workspace state before selecting the target branch"],"tags":["git","branch-not-found","absorb","rust"],"backgroundTag":"resource-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}