gitbutlerapp/gitbutler · error
Could not find CLI id ' ' in IdMap
Error message
Could not find {kind} CLI id '{short_id}' in IdMap What it means
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.
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
Example fix
// before but squash f3 # stale id from before a rebase // after but status # refresh but squash <fresh-id>
Defensive patterns
Strategy: validation
Validate before calling
let valid = but_status_ids().iter().any(|i| i.starts_with(short_id));
if !valid { eprintln!("'{short_id}' matches nothing; refresh with `but status`"); } Try / catch
match resolve_cli_id(kind, short_id, repo) {
Err(e) if e.to_string().contains("Could not find") => {
eprintln!("Id '{short_id}' is stale or wrong kind; re-run `but status`.");
}
other => other?,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
- Branch " " has no conflicted commits.
- Branch ' ' not found. Available branches
- CLI id ' ' is ambiguous for in IdMap
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/4de78751220c6efe.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/status/mod.rs:1875
]),
)?;
}
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
}
})
}
View on GitHub (pinned to 58e5313667)