{"record":{"id":"527d665a8ae396fe","repo":"gitbutlerapp/gitbutler","slug":"failed-to-create-blank-commit-in-leftmost-stack","errorCode":null,"errorMessage":"Failed to create blank commit in leftmost stack","messagePattern":"Failed to create blank commit in leftmost stack","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/legacy/absorb.rs","lineNumber":495,"sourceCode":"            .first()\n            .ok_or_else(|| anyhow::anyhow!(\"Stack has no branches\"))?;\n        commit_insert_blank_only_impl(\n            ctx,\n            RelativeTo::Reference(branch.reference.clone()),\n            InsertSide::Below,\n            DryRun::No,\n            perm,\n        )?;\n\n        // Now fetch the stack details again to get the newly created commit\n        let stack_details = crate::legacy::workspace::stack_details(ctx, Some(stack_id))?;\n        if let Some(branch) = stack_details.branch_details.first()\n            && let Some(commit) = branch.commits.first()\n        {\n            return Ok((stack_id, commit.id, AbsorptionReason::DefaultStack));\n        }\n\n        anyhow::bail!(\"Failed to create blank commit in leftmost stack\");\n    }\n\n    anyhow::bail!(\n        \"Unable to determine target commit for unassigned change: {}\",\n        candidate.hunk.path\n    );\n}\n\n/// Prepare commit absorptions with commit summaries\n///\n/// This returns a vector of absorption information, sorted and ready for processing.\nfn prepare_commit_absorptions(\n    ctx: &Context,\n    changes_by_commit: GroupedChanges,\n) -> anyhow::Result<Vec<CommitAbsorption>> {\n    let mut commit_absorptions = Vec::new();\n\n    // Cache the stack details to determine the commit order","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/2497b8007aa4a1922dae9a805b32ffe5b5037785/crates/but-api/src/legacy/absorb.rs#L477-L513","documentation":"Priority 3 fallback: the default (first) stack's first branch had no commits, a blank commit was inserted below it, and the re-fetched stack details still show no commits — so default-target absorption cannot proceed.","triggerScenarios":"Same shape as the assigned-stack variant: the blank-commit insert succeeded but the refreshed workspace view still reports an empty first branch, due to stale cache or concurrent ref/workspace mutation.","commonSituations":"Racing pushes or branch updates; a second process writing the project; cache invalidation gap after the insert.","solutions":["Reload the workspace and retry the absorb once","Verify the first stack's branch shows the blank commit; if yes, the retry succeeds","Eliminate concurrent writers (close other GitButler/git surfaces) and retry","Report reproducible cases with tracing logs of the insert"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"let stacks = workspace_stacks(ctx)?;\nlet first_ok = stacks.first()\n    .and_then(|s| s.id)\n    .map(|id| workspace_stack_details(ctx, id).map(|d| !d.branch_details.is_empty()).unwrap_or(false))\n    .unwrap_or(false);\nif !first_ok {\n    // expect the blank-commit fallback; be ready to reload and retry once\n}","typeGuard":null,"tryCatchPattern":"match absorption_plan_with_perm(ctx, target.clone(), perm) {\n    Err(e) if e.to_string().contains(\"Failed to create blank commit in leftmost stack\") => {\n        reload_workspace(ctx);\n        absorption_plan_with_perm(ctx, target, perm) // one retry after cache drop\n    }\n    other => other,\n}","preventionTips":["Avoid concurrent writers while absorbing into an empty default stack","Reload workspace state between retry attempts","Capture logs when insert succeeds but the refetch misses it"],"tags":["git","absorb","commit-insert","default-stack","race-condition"],"backgroundTag":"state-refresh-mismatch","analyzedSha":"2497b8007aa4a1922dae9a805b32ffe5b5037785","analyzedAt":"2026-08-17T00:30:25.648Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}