gitbutlerapp/gitbutler · error · anyhow::Error
Could not resolve stack '{stack}' by UUID or workspace branc
Error message
Could not resolve stack '{stack}' by UUID or workspace branch name What it means
`resolve_stack_id()` in the `but api unapply-stack` debug command accepts either a stack UUID (parsed as `StackId`) or a workspace branch name matched against each stack segment's ref name (full or shortened). If the argument parses as neither a UUID nor any stack's branch name, it bails. Note the UUID attempt is tried first, so any argument that fails both lookups lands here.
Source
Thrown at crates/but-debug/src/command/api.rs:86
stack.segments.iter().any(|segment| {
segment.ref_name().is_some_and(|ref_name| {
ref_name.as_bstr() == name.as_bytes()
|| ref_name.shorten().as_bstr() == name.as_bytes()
})
})
}
if let Ok(stack_id) = stack.parse::<StackId>() {
return Ok(stack_id);
}
let (_guard, _repo, workspace, _db) = ctx.workspace_and_db()?;
let mut matches = workspace.stacks.iter().filter_map(|workspace_stack| {
stack_matches(workspace_stack, stack)
.then_some(workspace_stack.id)
.flatten()
});
let Some(stack_id) = matches.next() else {
bail!("Could not resolve stack '{stack}' by UUID or workspace branch name");
};
if matches.next().is_some() {
bail!("Stack name '{stack}' is ambiguous in the current workspace");
}
Ok(stack_id)
}
View on GitHub (pinned to caf1f223d3)
Solutions
- List the workspace's stacks and their exact branch names first (e.g. `but api branch-list`) and copy the exact ref or id.
- Use the full ref (`refs/heads/<branch>`) if the short name doesn't match.
- Prefer the stack UUID, which is unambiguous and skips name matching entirely.
- Confirm you're in the right workspace/project — stacks from another project will never match.
Example fix
# before but api unapply-stack feautre-x # typo # after but api branch-list # find exact name/id but api unapply-stack feature-x # or the stack UUID
Defensive patterns
Strategy: validation
Validate before calling
# Shell — resolve the stack id before running the command
but api branch-list > /tmp/stacks.txt
grep -F "<name>" /tmp/stacks.txt || { echo "no such stack"; exit 1; } Prevention
- Script against stack UUIDs, not branch names — UUIDs never depend on workspace content.
- Run `but api branch-list` first and copy exact ref names or ids.
- Remember matching accepts both full and shortened ref names; prefer the full `refs/heads/<branch>` form.
When it happens
Trigger: Running `but api unapply-stack <name>` where `<name>` is not a valid StackId and no workspace stack has a segment ref equal (or shortenable) to it — typo, branch not in the workspace, or stack already deleted.
Common situations: Typos in branch names; referring to a plain git branch that was never imported as a stack; stack renamed or removed since it was listed; UUID copied with a stray character.
Related errors
- Stack name '{stack}' is ambiguous in the current workspace
- Failed to parse diff header
- No stack selected!
- BUG: It should not be possible to omit sources
- implement list and call recursively
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/c3436c43ae16119e.
Report an issue: GitHub.