gitbutlerapp/gitbutler · error
Stack name ' ' is ambiguous in the current workspace
Error message
Stack name '{stack}' is ambiguous in the current workspace What it means
resolve_stack_id found more than one stack in the workspace matching the supplied identifier, so the result would be ambiguous. Rather than picking an arbitrary stack, it bails asking the caller to disambiguate. A single match returns Ok(stack_id).
Solutions
- Use the full, exact stack UUID instead of a name or prefix so the match is unique
- Rename one of the conflicting workspace branches so names are unique, then retry
- Unapply/archive one of the duplicate stacks first, then reference the remaining one
- List workspace.stacks and pass the stack id of the exact stack you intend
Example fix
// before let id = api.resolve_stack_id(&mut ws, "feature")?; // matches two stacks // after let id = api.resolve_stack_id(&mut ws, "0f3b9c1e-4d2a-...full-uuid")?;
Defensive patterns
Strategy: validation
Validate before calling
let hits: Vec<_> = workspace.stacks.iter().filter(|s| stack_matches(s, stack)).collect();
if hits.len() > 1 { eprintln!("ambiguous: use the full UUID"); } Try / catch
match api.resolve_stack_id(&mut ws, stack) {
Err(e) if e.to_string().contains("is ambiguous") => eprintln!("pass the full stack UUID instead"),
other => other?,
} Prevention
- Prefer full stack UUIDs over name/prefix matching in scripts
- Keep workspace branch names unique across stacks
- Deduplicate or archive stale stacks with overlapping names
When it happens
Trigger: Calling resolve_stack_id (e.g. via unapply_stack) with a `stack` string that matches the UUID prefix or workspace branch name of two or more entries in workspace.stacks — the second call to matches.next() returns Some.
Common situations: Two stacks whose branch names share the matched name (e.g. same branch name pushed in different stacks), a UUID prefix that collides with another stack's id, or duplicated branch names after copying stacks between workspaces.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Could not resolve stack
- Ambiguous branch ' ', matches multiple items
- Ambiguous branch identifier
- Cannot compute diff specs for stacks
- CLI id ' ' is ambiguous for in IdMap
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/85f579c265b84bb3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-debug/src/command/api.rs:88
ref_name == name || 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 58e5313667)