{"record":{"id":"4dd5397e0b11368b","repo":"gitbutlerapp/gitbutler","slug":"failed-to-create-blank-commit-in-stack-stack-id","errorCode":null,"errorMessage":"Failed to create blank commit in stack: {stack_id:?}","messagePattern":"Failed to create blank commit in stack: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/legacy/absorb.rs","lineNumber":455,"sourceCode":"            return Ok((stack_id, commit_id, AbsorptionReason::StackAssignment));\n        }\n\n        // If there are no commits in the target branch, 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        // 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, branch_ref)? {\n            return Ok((stack_id, commit_id, AbsorptionReason::StackAssignment));\n        }\n\n        anyhow::bail!(\"Failed to create blank commit in stack: {stack_id:?}\");\n    }\n\n    // Priority 3: If no assignment, find the topmost commit of the leftmost lane\n    if let Some(stack_id) = workspace.stacks.first().and_then(|stack| stack.id) {\n        let (reference, commit_id) = target_segment(workspace, stack_id, None)?;\n        if let Some(commit_id) = commit_id {\n            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","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/legacy/absorb.rs#L437-L473","documentation":"`ensure_target_commit` throws this when, to absorb changes for an assigned stack, it creates a blank commit in the stack and then re-projects the workspace — but the freshly created commit cannot be found via `target_segment`, meaning the blank commit did not materialize as the stack's tip commit. This is an internal consistency failure of the stack-projection step, so the operation bails.","triggerScenarios":"Calling hunk/change absorption where the stack-assignment path (Priority 2) creates a blank commit in `stack_id`, re-reads `head_info`, but `target_segment(workspace, stack_id, branch_ref)` returns `(_, None)` — the projected tip commit is missing.","commonSituations":"Concurrent workspace mutations (another client/process rebasing the stack between commit creation and re-projection); stack state that cannot be projected consistently (e.g. conflicting ref updates); bugs in the workspace projection after automation touched refs.","solutions":["Retry the absorb operation — a transient concurrent mutation may have caused the failed projection.","Refresh the workspace state (`but pull`, re-open the project) and verify the stack is intact, then retry.","If reproducible, inspect for concurrent GitButler clients or ref-mutating automation and report a bug — this is an internal invariant violation."],"exampleFix":"// before\nabsorb(hunks)  // Err: Failed to create blank commit in stack: StackId(..)\n// after\nbut pull; // refresh workspace\nassert_stack_intact(stack_id);\nabsorb(hunks)","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  await api.absorb(hunks);\n} catch (e) {\n  if (String(e).includes('Failed to create blank commit in stack')) {\n    await api.refreshWorkspace(); // re-project stacks, ensure single client\n    await api.absorb(hunks);      // retry once; persisting failures are a bug\n  } else throw e;\n}","preventionTips":["Run only one GitButler client/process against a workspace during absorb operations.","Refresh workspace state before absorb if other tooling may have mutated refs.","Treat repeated occurrences as an internal bug: capture the stack state and report it."],"tags":["git","absorb","stack-projection","internal-error"],"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"}