gitbutlerapp/gitbutler · error
Failed to create blank commit in leftmost stack
Error message
Failed to create blank commit in leftmost stack
What it means
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.
Source
Thrown at crates/but-api/src/legacy/absorb.rs:495
.first()
.ok_or_else(|| anyhow::anyhow!("Stack has no branches"))?;
commit_insert_blank_only_impl(
ctx,
RelativeTo::Reference(branch.reference.clone()),
InsertSide::Below,
DryRun::No,
perm,
)?;
// Now fetch the stack details again to get the newly created commit
let stack_details = crate::legacy::workspace::stack_details(ctx, Some(stack_id))?;
if let Some(branch) = stack_details.branch_details.first()
&& let Some(commit) = branch.commits.first()
{
return Ok((stack_id, commit.id, AbsorptionReason::DefaultStack));
}
anyhow::bail!("Failed to create blank commit in leftmost stack");
}
anyhow::bail!(
"Unable to determine target commit for unassigned change: {}",
candidate.hunk.path
);
}
/// Prepare commit absorptions with commit summaries
///
/// This returns a vector of absorption information, sorted and ready for processing.
fn prepare_commit_absorptions(
ctx: &Context,
changes_by_commit: GroupedChanges,
) -> anyhow::Result<Vec<CommitAbsorption>> {
let mut commit_absorptions = Vec::new();
// Cache the stack details to determine the commit orderView on GitHub (pinned to 2497b8007a)
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
Defensive patterns
Strategy: retry
Validate before calling
let stacks = workspace_stacks(ctx)?;
let first_ok = stacks.first()
.and_then(|s| s.id)
.map(|id| workspace_stack_details(ctx, id).map(|d| !d.branch_details.is_empty()).unwrap_or(false))
.unwrap_or(false);
if !first_ok {
// expect the blank-commit fallback; be ready to reload and retry once
} Try / catch
match absorption_plan_with_perm(ctx, target.clone(), perm) {
Err(e) if e.to_string().contains("Failed to create blank commit in leftmost stack") => {
reload_workspace(ctx);
absorption_plan_with_perm(ctx, target, perm) // one retry after cache drop
}
other => other,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Racing pushes or branch updates; a second process writing the project; cache invalidation gap after the insert.
Related errors
- Failed to create blank commit in stack: {stack_id:?}
- No uncommitted changes found for the selected files
- Failed to determine target commit for hunk absorption due to
- Stack has no branches
- Unable to determine target commit for unassigned change: {}
AI-assisted analysis of gitbutlerapp/gitbutler@2497b8007a (2026-08-17).
Data as JSON: /api/errors/527d665a8ae396fe.
Report an issue: GitHub.