{"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":"validation","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/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/legacy/show.rs#L65-L101","documentation":"In `but show` (crates/but/src/command/legacy/show.rs:83), when the argument resolves to exactly one IdMap entry, only CliId::Commit and CliId::Branch are showable. Every other CliId variant (uncommitted file/hunk, path prefix, committed file, the uncommitted area, a worktree, a stack) bails, with kind_for_humans() naming the actual kind.","triggerScenarios":"Running `but show <short-id>` where the ID belongs to a stack, worktree, uncommitted area, committed file, or path prefix — e.g. copying a stack or worktree ID from `but status` output and passing it to show.","commonSituations":"Assuming every short ID printed by status works with every subcommand; scripted use of IDs without checking their kind; stale docs or examples.","solutions":["Pass a commit SHA or a branch CLI ID to `but show`.","Use the command matching the entity kind: stack/branch subcommands for stacks and branches, `but status` for uncommitted items.","Re-run `but status` and read the entity kind shown next to the ID before reusing it."],"exampleFix":"# before\nbut show s7      # s7 is a stack ID\n# Target must be a commit ID or branch, not a stack\n\n# after\nbut branch list   # inspect stacks/branches\nbut show 4f2a     # a commit short ID","handlingStrategy":"type-guard","validationCode":"let ids = id_map.lookup(arg);\nif ids.len() == 1 && !matches!(ids[0], CliId::Commit { .. } | CliId::Branch(_)) {\n    // route to the right command for this kind instead of `but show`\n}","typeGuard":"fn is_showable_target(id: &CliId) -> bool {\n    matches!(id, CliId::Commit { .. } | CliId::Branch(_))\n}","tryCatchPattern":"match cli_ids[0] {\n    CliId::Commit { .. } | CliId::Branch(_) => { /* proceed */ }\n    other => anyhow::bail!(\"not showable: {} — use the matching subcommand\", other.kind_for_humans()),\n}","preventionTips":["Check the entity kind printed next to every short ID before passing it to a command.","In automation, resolve IDs once and dispatch by kind_for_humans().","Remember `but show` accepts only commit SHAs and branch IDs."],"tags":["cli","argument-type","id-resolution","validation"],"backgroundTag":"invalid-target-type","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}