gitbutlerapp/gitbutler · error
CLI id ' ' is ambiguous for in IdMap
Error message
CLI id '{short_id}' is ambiguous for {kind} in IdMap What it means
The same id-resolution helper raises this when the user's short id matches MORE THAN ONE entity of the requested kind in the IdMap. The id is too short/ambiguous, so the operation is refused rather than guessing which entity was meant.
Solutions
- use a longer, more specific id — copy the full CLI id from `but status` output
- re-run `but status` and confirm the exact id of the intended entity
- if scripting, match ids by full string rather than short prefix
Example fix
// before but squash a // after but squash ab12f # unambiguous id from `but status`
Defensive patterns
Strategy: validation
Validate before calling
let matches = but_status_ids().iter().filter(|i| i.starts_with(short_id)).count();
if matches != 1 { eprintln!("'{short_id}' matches {matches} ids; use a longer id"); } Try / catch
match resolve_cli_id(kind, short_id, repo) {
Err(e) if e.to_string().contains("ambiguous") => {
eprintln!("Shorten no more: use the full id from `but status`.");
}
other => other?,
} Prevention
- use full CLI ids instead of 1-2 character prefixes
- confirm the exact id in `but status` output before invoking
- in scripts, validate uniqueness of the prefix beforehand
When it happens
Trigger: Supplying a very short prefix (1-2 characters) that several active CLI ids share, especially in large workspaces with many branches/files whose generated ids collide on the prefix.
Common situations: Typing `but squash a` when multiple ids start with 'a'; scripting with truncated ids; working in a workspace with many similarly-named stacks/files.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- Ambiguous branch ' ', matches multiple items
- Ambiguous branch identifier
- Commit ID ' ' is ambiguous. Please provide more characters…
- Commit ID ' ' is ambiguous. Found matches
- Could not find CLI id ' ' in IdMap
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/806e87c53e9d1523.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/status/mod.rs:1878
Ok(())
}
fn lookup_cli_id_for_short_id(
id_map: &IdMap,
repo: &gix::Repository,
short_id: &str,
predicate: impl Fn(&CliId) -> bool,
kind: &str,
) -> anyhow::Result<CliId> {
let mut matches = id_map.parse_using_repo(short_id, repo)?;
matches.retain(|id| id.short_string() == short_id && predicate(id));
match matches.len() {
1 => Ok(matches.remove(0)),
0 => Err(anyhow::anyhow!(
"Could not find {kind} CLI id '{short_id}' in IdMap"
)),
_ => Err(anyhow::anyhow!(
"CLI id '{short_id}' is ambiguous for {kind} in IdMap"
)),
}
}
fn status_from_changes(changes: &[ui::TreeChange], path: BString) -> Option<ui::TreeStatus> {
changes.iter().find_map(|change| {
if change.path_bytes == path {
Some(change.status.clone())
} else {
None
}
})
}
enum CommitChanges<'a> {
Workspace(&'a [TreeChangeWithId]),
Remote(&'a [but_core::TreeChange]),View on GitHub (pinned to 58e5313667)