{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/status/mod.rs","lineNumber":1855,"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.to_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_letter(status: &TreeStatus) -> char {\n    match status {\n        TreeStatus::Addition { .. } => 'A',\n        TreeStatus::Deletion { .. } => 'D',\n        TreeStatus::Modification { .. } => 'M',\n        TreeStatus::Rename { .. } => 'R',\n    }\n}\n\npub fn status_letter_ui(status: &ui::TreeStatus) -> char {\n    match status {\n        ui::TreeStatus::Addition { .. } => 'A',\n        ui::TreeStatus::Deletion { .. } => 'D',","sourceCodeStart":1837,"sourceCodeEnd":1873,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/status/mod.rs#L1837-L1873","documentation":"Thrown by `lookup_cli_id_for_short_id`: after filtering IdMap matches by exact short-string equality and the kind predicate, more than one entry survives. The short id is too short to name exactly one entity of that kind, so the command refuses to guess.","triggerScenarios":"Two commits (or branches) share the same short id string in the IdMap — common right after history-rewriting operations (amend, rebase, ship) that create parallel entries — and the user passes that id to a command resolving a single entity.","commonSituations":"Short ids after amend/rebase when old and new entries coexist; large workspaces where the short-id space for that kind collided; scripts using a fixed prefix length that is too short for the workspace's size.","solutions":["Use more characters of the id to disambiguate — extend the prefix until it is unique","List the current ids (`but status` / the relevant list command) to see which entries collide and pick the right one","In scripts, prefer full-length git shas over short CLI ids to avoid collisions entirely"],"exampleFix":"# before: 'c3' matches two entries\nbut <cmd> c3\n\n# after: longer prefix\nbut <cmd> c31","handlingStrategy":"validation","validationCode":"let hits: Vec<_> = id_map\n    .parse_using_repo(short_id, repo)?\n    .into_iter()\n    .filter(|id| id.to_short_string() == short_id && kind_predicate(id))\n    .collect();\nif hits.len() > 1 {\n    anyhow::bail!(\"'{short_id}' matches {} {kind} ids; extend the prefix\", hits.len());\n}","typeGuard":null,"tryCatchPattern":"match lookup_cli_id_for_short_id(id_map, repo, short_id, |i| is_commit(i), \"commit\") {\n    Ok(cli_id) => { /* use */ }\n    Err(err) if err.to_string().contains(\"ambiguous\") => {\n        // lengthen the prefix by one or more characters and retry\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Extend short ids by a character or two until unique after rewrites/amends","Re-list ids after history-changing operations; old and new entries coexist and collide","Use full-length shas in automation to sidestep short-id collisions"],"tags":["rust","cli","tui","id-map","ambiguity","git"],"backgroundTag":"ambiguous-short-id","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}