{"record":{"id":"174b40dddf2159d0","repo":"gitbutlerapp/gitbutler","slug":"commit-id-str-does-not-refer-to-a-commit","errorCode":null,"errorMessage":"'{commit_id_str}' does not refer to a commit","messagePattern":"'(.+?)' does not refer to a commit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/resolve.rs","lineNumber":190,"sourceCode":"        );\n    }\n\n    // Extract the commit OID from the matched CliId\n    match &matches[0] {\n        CliId::Commit {\n            commit: CommitId { commit_id, .. },\n            id: _,\n        } => {\n            let commit_ref = theme::Commit(CommitIdRef {\n                commit_id: *commit_id,\n                change_id: id_map\n                    .change_id_ref(*commit_id)\n                    .map(|change_id| &change_id.change_id),\n            })\n            .to_string();\n            Ok((*commit_id, commit_ref))\n        }\n        _ => bail!(\"'{commit_id_str}' does not refer to a commit\"),\n    }\n}\n\nfn enter_resolution(ctx: &mut Context, out: &mut OutputChannel, commit_id_str: &str) -> Result<()> {\n    let t = theme::get();\n    use gix::{prelude::ObjectIdExt as _, revision::walk::Sorting};\n\n    let (commit_gix_oid, commit_ref) = parse_commit_id(ctx, commit_id_str)?;\n\n    // Get the commit and check if it's conflicted\n    let repo = ctx.repo.get()?;\n    let commit = repo\n        .find_commit(commit_gix_oid)\n        .context(\"Failed to find commit\")?;\n\n    if !commit.is_conflicted() {\n        bail!(\n            \"Commit {commit_ref} is not in a conflicted state. Only conflicted commits can be resolved.\"","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/resolve.rs#L172-L208","documentation":"Type guard in parse_commit_id: the identifier resolved to a CliId that is not a Commit variant (e.g. a branch, hunk, or worktree ID). Only commit identifiers can be used for conflict resolution, so a different ID must be supplied.","triggerScenarios":"`but resolve <id>` where the ID maps to a non-commit entity — e.g. passing a file path or branch name where the match falls into the non-commit arm of the match on matches[0].","commonSituations":"Passing a file path when a commit is expected; using a branch name instead of a commit ID; confusing `but resolve <path>` (worktree conflicts) with `but resolve <commit>` (commit resolution).","solutions":["Pass a commit ID from `but status` rather than a file path or branch name","To resolve uncommitted file conflicts, pass conflicted file paths only (with no commit-like target)","Check the entity type with `but status` before invoking"],"exampleFix":"// before\nbut resolve main        # branch name, not a commit id\n// after\nbut resolve 9f2c1ab     # actual commit id","handlingStrategy":"type-guard","validationCode":"if let Some(kind) = id_kind(input) { // 'commit' | 'file' | 'branch'\n    if kind != \"commit\" { eprintln!(\"{input} is not a commit id\"); }\n}","typeGuard":"fn is_commit_id(id: &str, ctx: &Context) -> bool {\n    matches!(id_kind(id, ctx), Some(Kind::Commit))\n}","tryCatchPattern":"if let Err(e) = parse_commit_id(ctx, input) {\n    if e.to_string().contains(\"does not refer to a commit\") {\n        eprintln!(\"{input} resolves to a non-commit; pass a commit id from 'but status'\");\n    }\n}","preventionTips":["Distinguish file paths, branch names, and commit IDs before calling","Use unambiguous commit IDs from `but status`","Do not pass branch names to commit-targeted commands"],"tags":["cli","commit","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"}