{"record":{"id":"806e87c53e9d1523","repo":"gitbutlerapp/gitbutler","slug":"cli-id-short-id-is-ambiguous-for-kind-in-idm","errorCode":null,"errorMessage":"CLI id '{short_id}' is ambiguous for {kind} in IdMap","messagePattern":"CLI id '(.+?)' is ambiguous for (.+?) in IdMap","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/status/mod.rs","lineNumber":1878,"sourceCode":"    Ok(())\n}\n\nfn lookup_cli_id_for_short_id(\n    id_map: &IdMap,\n    repo: &gix::Repository,\n    short_id: &str,\n    predicate: impl Fn(&CliId) -> bool,\n    kind: &str,\n) -> anyhow::Result<CliId> {\n    let mut matches = id_map.parse_using_repo(short_id, repo)?;\n    matches.retain(|id| id.short_string() == short_id && predicate(id));\n\n    match matches.len() {\n        1 => Ok(matches.remove(0)),\n        0 => Err(anyhow::anyhow!(\n            \"Could not find {kind} CLI id '{short_id}' in IdMap\"\n        )),\n        _ => Err(anyhow::anyhow!(\n            \"CLI id '{short_id}' is ambiguous for {kind} in IdMap\"\n        )),\n    }\n}\n\nfn status_from_changes(changes: &[ui::TreeChange], path: BString) -> Option<ui::TreeStatus> {\n    changes.iter().find_map(|change| {\n        if change.path_bytes == path {\n            Some(change.status.clone())\n        } else {\n            None\n        }\n    })\n}\n\nenum CommitChanges<'a> {\n    Workspace(&'a [TreeChangeWithId]),\n    Remote(&'a [but_core::TreeChange]),","sourceCodeStart":1860,"sourceCodeEnd":1896,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/status/mod.rs#L1860-L1896","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typing `but squash a` when multiple ids start with 'a'; scripting with truncated ids; working in a workspace with many similarly-named stacks/files.","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"],"exampleFix":"// before\nbut squash a\n// after\nbut squash ab12f   # unambiguous id from `but status`","handlingStrategy":"validation","validationCode":"let matches = but_status_ids().iter().filter(|i| i.starts_with(short_id)).count();\nif matches != 1 { eprintln!(\"'{short_id}' matches {matches} ids; use a longer id\"); }","typeGuard":null,"tryCatchPattern":"match resolve_cli_id(kind, short_id, repo) {\n    Err(e) if e.to_string().contains(\"ambiguous\") => {\n        eprintln!(\"Shorten no more: use the full id from `but status`.\");\n    }\n    other => other?,\n}","preventionTips":["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"],"tags":["cli","ambiguity","id-lookup"],"backgroundTag":"invalid-identifier-format","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"}