{"record":{"id":"6b18661a05236d10","repo":"gitbutlerapp/gitbutler","slug":"raw-id-resolved-to-more-than-one-hunk","errorCode":null,"errorMessage":"'{raw_id}' resolved to more than one hunk ({})","messagePattern":"'(.+?)' resolved to more than one hunk \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/utils/diff_rendering.rs","lineNumber":1408,"sourceCode":"    ctx: &'a Context,\n    id_map: &'a IdMap,\n    mut filter: F,\n) -> anyhow::Result<Vec<(&'a str, Arc<CliId>, &'a UncommittedHunk)>>\nwhere\n    F: FnMut(&UncommittedHunk) -> bool,\n{\n    let mut uncommitted_hunks = id_map\n        .uncommitted_hunks\n        .iter()\n        .filter(move |(_, hunk)| filter(hunk))\n        .map(|(raw_id, hunk)| {\n            let mut cli_ids = id_map.parse_using_context(raw_id, ctx)?;\n            if cli_ids.len() == 1 {\n                Ok((&**raw_id, Arc::new(cli_ids.remove(0)), hunk))\n            } else if cli_ids.is_empty() {\n                bail!(\"'{raw_id}' no found\")\n            } else {\n                bail!(\n                    \"'{raw_id}' resolved to more than one hunk ({})\",\n                    cli_ids.len()\n                )\n            }\n        })\n        .collect::<anyhow::Result<Vec<_>>>()?;\n\n    uncommitted_hunks.sort_by(|(id_a, _, hunk_a), (id_b, _, hunk_b)| {\n        (\n            &hunk_a.hunk.path,\n            hunk_a\n                .hunk\n                .hunk_header\n                .as_ref()\n                .map(|header| header.old_start),\n            id_a,\n        )\n            .cmp(&(","sourceCodeStart":1390,"sourceCodeEnd":1426,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/utils/diff_rendering.rs#L1390-L1426","documentation":"This error is thrown when a user-supplied hunk CLI id (e.g. an id passed to a `but diff`/`but show` style command) resolves via `id_map.parse_using_context` to more than one hunk instead of exactly one. The id is therefore ambiguous in the current context (the same short id maps to multiple candidate hunks), and the code refuses to guess which one was meant.","triggerScenarios":"Calling a but CLI command that takes a hunk id when `parse_using_context(raw_id, ctx)` returns a Vec with len > 1; typically a short/partial id prefix that matches several hunks in the resolution context.","commonSituations":"Typing an abbreviated hunk id that is a prefix of (or collides with) multiple hunk ids; referencing a hunk id after rebasing or editing commits so the id map contains multiple matches; using ids from stale output against a changed workspace.","solutions":["Re-run the listing command (e.g. `but status`/hunk output) to see the current ids and use the full, unambiguous id","Lengthen the id prefix so it matches exactly one hunk","Re-check whether the intended hunk still exists; if the workspace changed, refresh context before retrying"],"exampleFix":"// before\nbut diff abc\n// after\nbut diff abc123f   # use a longer id that resolves to a single hunk","handlingStrategy":"validation","validationCode":"// resolve the id first and check cardinality before using it\nlet ids = id_map.parse_using_context(raw_id, ctx)?;\nif ids.len() != 1 {\n    eprintln!(\"id '{raw_id}' is ambiguous ({} matches); use a longer id\", ids.len());\n    return Ok(());\n}","typeGuard":"fn is_unambiguous(ids: &[CliId]) -> bool { ids.len() == 1 }","tryCatchPattern":null,"preventionTips":["Copy full ids rather than short prefixes when scripting","Refresh `but status` output before reusing ids after rebase/edit operations","Fail fast on ids that resolve to more than one hunk instead of picking one"],"tags":["cli","ambiguous-identifier","hunk-resolution"],"backgroundTag":"invalid-identifier-format","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"}