{"record":{"id":"bd1f562ceccc3e38","repo":"gitbutlerapp/gitbutler","slug":"target-must-be-a-commit-id-or-branch-not","errorCode":null,"errorMessage":"Target must be a commit ID or branch, not {}","messagePattern":"Target must be a commit ID or branch, not (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/show.rs","lineNumber":83,"sourceCode":"        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            _ => {\n                bail!(\n                    \"Target must be a commit ID or branch, not {}\",\n                    cli_ids[0].kind_for_humans()\n                );\n            }\n        }\n    };\n\n    // Get commit and file details\n    let repo = ctx.repo.get()?;\n    let raw_commit = repo.find_commit(commit_id)?;\n    let decoded = raw_commit.decode()?;\n\n    // Get diff with first parent\n    let parent_id = raw_commit.parent_ids().next().map(|id| id.detach());\n    let tree_changes = but_core::diff::TreeChanges::from_trees(&repo, parent_id, commit_id)?;\n\n    // Extract change-id if present (try both header names)\n    let change_id = decoded","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/show.rs#L65-L101","documentation":"`but show` accepts a target that resolves to a commit ID or a branch `CliId` (branches are delegated to `show_branch`). Any other `CliId` kind (e.g. a file/hunk marker) cannot be 'shown' as a commit, so the command bails naming the kind via `kind_for_humans()`.","triggerScenarios":"Running `but show` with an ID that resolves to a non-commit, non-branch CLI ID — e.g. an uncommitted file or hunk ID produced by `but status`/marking — instead of a commit or branch ID.","commonSituations":"Passing a file marker ID from the TUI/status output to `show`; scripting that copies the wrong column of IDs; typos where a workspace entity ID is mistaken for a commit ID.","solutions":["Use a commit ID or branch name: `but show <commit-id|branch>`.","Check the ID's kind via `but status`/`but log` output; use the appropriate command for files/hunks instead of `show`.","If you intend to view a branch, pass the branch ID/name so `show_branch` runs."],"exampleFix":"// before: file marker ID\nbut show f:src/main.rs\n// error: Target must be a commit ID or branch, not file\n// after\nbut show 3f9c1ab   # or a branch name\nbut status         # for file-level info","handlingStrategy":"type-guard","validationCode":"if !matches!(cli_id, CliId::CommitId(_) | CliId::Branch(_)) {\n    eprintln!(\"but show expects a commit ID or branch; got {}\", cli_id.kind_for_humans());\n    std::process::exit(2);\n}","typeGuard":"fn is_showable(id: &CliId) -> bool {\n    matches!(id, CliId::CommitId(_) | CliId::Branch(_))\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().starts_with(\"Target must be a commit ID or branch\") => {\n        eprintln!(\"use `but status` for files/hunks; `but show` is for commits/branches\");\n    }\n    Err(e) => return Err(e),\n    Ok(v) => v,\n}","preventionTips":["Check the ID kind shown next to entries in `but status`/`but log` output","Route file/hunk IDs to the appropriate subcommand, not `show`","Branch targets: pass the branch name so show_branch runs"],"tags":["cli","invalid-argument","cli-id","show"],"backgroundTag":"invalid-argument-value","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"}