{"record":{"id":"d2d64eb3aeacb969","repo":"gitbutlerapp/gitbutler","slug":"commit-id-str-is-not-a-commit","errorCode":null,"errorMessage":"'{commit_id_str}' is not a commit","messagePattern":"'(.+?)' is not a commit","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/show.rs","lineNumber":64,"sourceCode":"                // 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) => {\n                // This is a branch identified by CLI ID, show the branch\n                return show_branch(ctx, out, &branch.name, verbose, &id_map);\n            }\n            _ => {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/show.rs#L46-L82","documentation":"Thrown by `but show <id>` resolution: `rev_parse_single` did resolve the input to an object, but `try_into_commit()` failed — the object is a tree, blob, or annotated tag rather than a commit. The show command only renders commits, so non-commit objects are rejected here.","triggerScenarios":"Passing a tree id (`git rev-parse HEAD^{tree}`), a blob sha from diff output, or an annotated tag object id where the command expects a commit-ish.","commonSituations":"Pasting the tree hash shown in `git write-tree` or cat-file output; confusion between `<tag>` (peels fine when passed by name) and the tag object's own sha; tooling that emits whatever oid it saw last.","solutions":["Resolve to the commit explicitly: `git rev-parse <id>^{commit}` and pass that sha","For tags, pass the tag name or use the peel syntax `<tag>^{}` instead of the tag object sha","If you really wanted to inspect a blob or tree, use `git show <sha>` / `git cat-file -p <sha>` — the but command is commit-only"],"exampleFix":"# before: tree object sha\nbut show $(git rev-parse HEAD^{tree})\n\n# after: the commit itself\nbut show $(git rev-parse HEAD^{commit})","handlingStrategy":"type-guard","validationCode":"let obj = repo.rev_parse_single(id.as_bytes())?.object()?;\nif obj.kind != gix::objs::ObjectType::Commit {\n    anyhow::bail!(\"{id} is a {:?}; pass a commit-ish like '<rev>^{{commit}}'\", obj.kind);\n}","typeGuard":"fn as_commit_id(obj: gix::objs::ObjectRef<'_>) -> Option<gix::hash::ObjectId> {\n    obj.try_into_commit().ok().map(|commit| commit.id)}\n// or on the id: repo.find_object(id)?.try_into_commit().is_ok()","tryCatchPattern":"match repo.rev_parse_single(id.as_bytes()) {\n    Ok(id) => match id.object().and_then(|o| Ok(o.try_into_commit()?)) {\n        Ok(commit) => { /* show commit */ }\n        Err(_) => { /* peel: rev_parse \"id^{commit}\" or reject with guidance */ }\n    },\n    Err(err) => return Err(err.into()),\n}","preventionTips":["Always resolve with the `<rev>^{commit}` peel suffix before passing ids around","Pass branch/tag names rather than raw object shas when the command accepts them","Use `git cat-file -t <sha>` to check an object's type before pasting it"],"tags":["rust","cli","git","object-type","rev-parse"],"backgroundTag":"object-is-not-a-commit","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}