{"record":{"id":"5fe147350b925be0","repo":"gitbutlerapp/gitbutler","slug":"commit-commit-id-str-not-found","errorCode":null,"errorMessage":"Commit '{commit_id_str}' not found","messagePattern":"Commit '(.+?)' not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/show.rs","lineNumber":60,"sourceCode":"            let head_name = branch.name.clone();\n            if head_name == commit_id_str\n                || head_name.to_lowercase() == commit_id_str.to_lowercase()\n            {\n                // Found the branch in a stack\n                return show_branch(ctx, out, &head_name, verbose, &id_map);\n            }\n        }\n    }\n\n    // Not a branch, resolve the commit ID through the IdMap\n    let cli_ids = id_map.parse_using_context(commit_id_str, ctx)?;\n\n    let commit_id = if cli_ids.is_empty() {\n        // If not found in IdMap, try to parse as a git commit ID directly\n        let repo = ctx.repo.get()?;\n        let obj = repo\n            .rev_parse_single(commit_id_str)\n            .map_err(|_| anyhow::anyhow!(\"Commit '{commit_id_str}' not found\"))?;\n        let commit = obj\n            .object()?\n            .try_into_commit()\n            .map_err(|_| anyhow::anyhow!(\"'{commit_id_str}' is not a commit\"))?;\n        commit.id\n    } else if cli_ids.len() > 1 {\n        bail!(\n            \"Commit ID '{}' is ambiguous. Found {} matches\",\n            commit_id_str,\n            cli_ids.len()\n        );\n    } else {\n        match &cli_ids[0] {\n            CliId::Commit {\n                commit: CommitId { commit_id, .. },\n                id: _,\n            } => *commit_id,\n            CliId::Branch(branch) => {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/show.rs#L42-L78","documentation":"Thrown by `but show <id>` resolution: the IdMap lookup returned no CLI ids, so the string is fall back to `repo.rev_parse_single(commit_id_str)`. If gix cannot resolve the revision at all, this error is raised — the input is neither a known CLI short id, nor any ref/oid expression git understands.","triggerScenarios":"Passing a mistyped hex sha, a too-short prefix gix refuses to guess, an object id that no longer exists (pruned by gc, beyond a shallow-clone boundary), or a ref name typo — and none of these resolve via rev-parse.","commonSituations":"Copying a truncated or edited sha from logs/chat; referencing commits after `git gc --prune` or in shallow CI clones; reusing CLI short ids from a different workspace whose IdMap doesn't know them; old ids after history rewrite.","solutions":["Verify the id resolves in the same repo: `git rev-parse <id>` — if git also fails, the id is stale or wrong","Use the short id printed by current `but status` / `but log` output so IdMap resolution succeeds first","If the commit should exist but is missing (shallow/pruned), fetch it: `git fetch origin <sha>` (needs uploadpack.allowAnySHA1InWant on the server) and retry","Reference a branch name instead of a raw sha when possible"],"exampleFix":"# before: stale/mistyped sha\nbut show 4f2ac91\n\n# after: confirm it exists, else take a fresh id\n git rev-parse 4f2ac91   # fails -> copy a current id instead\nbut status               # lists fresh CLI ids\nbut show c3","handlingStrategy":"validation","validationCode":"let repo = ctx.repo.get()?;\nif repo.rev_parse_single(id.as_bytes()).is_err() {\n    anyhow::bail!(\"id {id} does not resolve; run 'but status' for current ids or 'git rev-parse {id}' to check\");\n}","typeGuard":null,"tryCatchPattern":"match resolve_commit(id_map, ctx, id) {\n    Ok(commit_id) => { /* show */ }\n    Err(err) if err.to_string().contains(\"not found\") => {\n        // suggest fresh 'but status' ids and 'git rev-parse' verification\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Prefer ids printed by the current `but status`/`but log` run over shas copied from elsewhere","Verify questionable shas with `git rev-parse` before passing them","In scripts, resolve ids in the same invocation that listed them; never cache them across rewrites"],"tags":["rust","cli","git","rev-parse","commit-lookup","id-map"],"backgroundTag":"commit-not-found","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}