{"record":{"id":"4de78751220c6efe","repo":"gitbutlerapp/gitbutler","slug":"could-not-find-kind-cli-id-short-id-in-idmap","errorCode":null,"errorMessage":"Could not find {kind} CLI id '{short_id}' in IdMap","messagePattern":"Could not find (.+?) CLI id '(.+?)' in IdMap","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/status/mod.rs","lineNumber":1875,"sourceCode":"            ]),\n        )?;\n    }\n    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","sourceCodeStart":1857,"sourceCodeEnd":1893,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/status/mod.rs#L1857-L1893","documentation":"This helper resolves a user-supplied short CLI id against the IdMap (the map of human-friendly ids to git entities), filtering matches by an entity-kind predicate. Zero surviving matches yields this error: no object of the requested kind (`{kind}`, e.g. commit, branch, file) corresponds to the given short id.","triggerScenarios":"Passing a short id to a command (`but squash <id>`, `but assign`, etc.) where the id does not exist in the IdMap, is stale after a workspace mutation/rebase, or is an id of a different kind than the predicate expects.","commonSituations":"Using a commit id where a file/branch id is expected, referencing ids captured before a `but sync`/rebase changed the workspace, or abbreviating an id too aggressively so it matches nothing.","solutions":["re-run `but status` to get fresh CLI ids and use one of those","verify the id kind matches what the command expects (commit vs branch vs file)","use the full git object id instead if the CLI supports it, so lookup falls back to rev-parse"],"exampleFix":"// before\nbut squash f3    # stale id from before a rebase\n// after\nbut status        # refresh\nbut squash <fresh-id>","handlingStrategy":"validation","validationCode":"let valid = but_status_ids().iter().any(|i| i.starts_with(short_id));\nif !valid { eprintln!(\"'{short_id}' matches nothing; refresh with `but status`\"); }","typeGuard":null,"tryCatchPattern":"match resolve_cli_id(kind, short_id, repo) {\n    Err(e) if e.to_string().contains(\"Could not find\") => {\n        eprintln!(\"Id '{short_id}' is stale or wrong kind; re-run `but status`.\");\n    }\n    other => other?,\n}","preventionTips":["capture ids fresh from `but status` each session","match the id kind to the command (commit vs file vs branch)","prefer full ids in scripts"],"tags":["cli","id-lookup","not-found"],"backgroundTag":"record-not-found","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"}