gitbutlerapp/gitbutler · error
Unable to determine target commit for unassigned change
Error message
Unable to determine target commit for unassigned change: {} What it means
When absorbing an unassigned change, the code must determine which commit the change belongs to. If no candidate stack/commit could be resolved for the hunk's path — neither via assignment rules nor the default (leftmost) stack — this error is thrown with the offending file path. It means absorb cannot place the change anywhere.
Solutions
- Create at least one stack (commit) in the workspace before absorbing
- Assign the file to a stack via workspace assignment rules
- Verify the workspace is correctly initialized (but workspace status)
- Move the change manually with git instead of absorb
Defensive patterns
Strategy: try-catch
Validate before calling
const stacks = await getWorkspaceStacks(projectId);
if (!stacks.length) throw new Error('No stacks: cannot absorb'); Try / catch
try {
await absorbChanges(projectId, changes);
} catch (e) {
if (String(e).startsWith('Unable to determine target commit')) {
// surface which file path was unplaceable to the user
showToast(`Cannot place change: ${e.message}`);
} else throw e;
} Prevention
- Create a commit/stack before absorbing unassigned changes
- Assign files to stacks with assignment rules
- Check that the changed paths match an existing stack
When it happens
Trigger: Calling absorb with an unassigned change whose path cannot be matched to any stack, and ensure_target_commit also failed to produce a default target commit.
Common situations: Absorbing hunks in a workspace with no stacks at all; path matching rules out every stack; a corrupted or freshly-initialized workspace without a default stack.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Failed to create blank commit in leftmost stack
- a committed transaction always materializes a workspace
- Branch ` ` is not part of the current workspace
- Branch not found
- Cannot unapply anonymous segments yet even if they have a…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/3225b474e2f7cbd0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/legacy/absorb.rs:483
// If the first stack has no commits, create a blank commit first
commit_insert_blank_only_impl(
ctx,
RelativeTo::Reference(reference),
InsertSide::Below,
DryRun::No,
perm,
)?;
// Now project the workspace again to see the newly created commit
*workspace = crate::legacy::workspace::head_info(ctx)?;
if let (_, Some(commit_id)) = target_segment(workspace, stack_id, None)? {
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();
// The workspace projection carries every stack's segments and commits in order
let workspace = crate::legacy::workspace::head_info(ctx)?;
let all_stack_ids = changes_by_commit
.keys()View on GitHub (pinned to 58e5313667)