{"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":480,"sourceCode":"            return Ok((stack_id, commit_id, AbsorptionReason::DefaultStack));\n        }\n\n        // If the first stack has no commits, create a blank commit first\n        commit_insert_blank_only_impl(\n            ctx,\n            RelativeTo::Reference(reference),\n            InsertSide::Below,\n            DryRun::No,\n            perm,\n        )?;\n\n        // Now project the workspace again to see the newly created commit\n        *workspace = crate::legacy::workspace::head_info(ctx)?;\n        if let (_, Some(commit_id)) = target_segment(workspace, stack_id, None)? {\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    // The workspace projection carries every stack's segments and commits in order","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/legacy/absorb.rs#L462-L498","documentation":"During absorb, when an unassigned change is grouped, ensure_target_commit tries to find (or create) a blank commit at the top of the leftmost stack to absorb the change into. If after re-projecting the workspace the target segment still cannot be resolved, this error is thrown. It indicates the workspace could not provide a valid target commit for the change.","triggerScenarios":"Calling absorb (via group_changes_by_target_commit) on a workspace whose leftmost stack has no resolvable target segment even after creating a blank commit; workspace re-projection returns no commit for the stack.","commonSituations":"Absorbing unassigned hunks in a workspace with an empty or corrupted leftmost stack; repository state changed mid-operation (e.g. concurrent git operations or external tooling rewrote refs); workspace projection returning stale/empty data.","solutions":["Re-run project/workspace refresh and retry the absorb operation","Inspect the leftmost stack state (gitbutler workspace refs) and repair or recreate the stack","Check for concurrent processes modifying the repo during absorb","Reproduce with but workspace status and report if projection consistently fails"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const ws = await getWorkspaceStatus(projectId);\nif (!ws.stacks?.length) { await createInitialStack(projectId); }","typeGuard":null,"tryCatchPattern":"try {\n  await absorbChanges(projectId, changes);\n} catch (e) {\n  if (String(e).includes('Failed to create blank commit')) {\n    await refreshWorkspace(projectId);\n    await absorbChanges(projectId, changes);\n  } else throw e;\n}","preventionTips":["Ensure at least one applied stack exists before absorbing","Avoid running concurrent git operations during absorb","Refresh workspace projection after ref-modifying operations"],"tags":["rust","workspace","absorb"],"backgroundTag":"internal-invariant-violation","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"}