{"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":null,"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/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/show.rs#L46-L82","documentation":"After `rev_parse_single` successfully resolves the string, `show_commit` tries `try_into_commit()`. This error is returned when the resolved git object exists but is not a commit — e.g. it is a blob, tree, or tag object.","triggerScenarios":"Calling `but show <id>` where `<id>` resolves to a non-commit object: a tree hash, blob hash, a file path (rev-parse of `HEAD:path`), or an annotated tag when the caller expects a commit id.","commonSituations":"Passing a file path to `but show`, copying a tree/blob hash from `git cat-file` output, or passing a tag ref string that resolves to the tag object.","solutions":["pass a commit id (from `but status` or `git log`) instead of a tree/blob/path id","if showing a file is intended, use `but diff` / `git show <path>` instead","deref the tag first, e.g. use the peeled commit id `git rev-parse <tag>^{commit}`"],"exampleFix":"// before\nbut show HEAD:src/main.rs        # resolves to a blob\n// after\nbut show $(git rev-parse HEAD)   # or a CLI id from `but status`","handlingStrategy":"validation","validationCode":"let kind = String::from_utf8_lossy(&Command::new(\"git\").args([\"cat-file\",\"-t\",id]).output().unwrap().stdout).trim().to_string();\nif kind != \"commit\" { eprintln!(\"{id} is a {kind}, not a commit\"); }","typeGuard":null,"tryCatchPattern":"match show_commit(ctx, id) {\n    Err(e) if e.to_string().contains(\"is not a commit\") => {\n        eprintln!(\"Pass a commit id (git rev-parse <ref>^{{commit}}) instead.\");\n    }\n    other => other?,\n}","preventionTips":["only pass commit ids to `but show`; use `but diff`/git for trees and blobs","peel tags with `<tag>^{commit}`","do not pass `rev:path` file expressions to commit-showing commands"],"tags":["git","cli","type-mismatch"],"backgroundTag":"type-mismatch","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"}