{"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":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/utils/diff_rendering.rs","lineNumber":1163,"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(&but_core::SingleHunk) -> bool,\n{\n    let mut uncommitted_hunks = id_map\n        .uncommitted_hunks\n        .iter()\n        .filter(move |(_, hunk)| filter(&hunk.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":1145,"sourceCodeEnd":1181,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/utils/diff_rendering.rs#L1145-L1181","documentation":"filter_uncommitted_hunks requires each raw hunk id to resolve to exactly one CLI-visible hunk. When parse_using_context expands one raw id into several CLI ids - because hunk splitting or diff context settings map one raw hunk to multiple displayed hunks - the selection is ambiguous and the count is reported.","triggerScenarios":"Hunk-splitting or diff-context configuration makes one raw hunk expand to multiple CLI hunks; selecting a coarse id after the presentation layer split hunks; the same path appearing in multiple contexts.","commonSituations":"Changing diff context settings between listing and selection, tools that collapse/expand hunks, programmatic callers passing aggregate ids.","solutions":["Re-list hunks and select a narrower, single-hunk id","Adjust hunk context/split settings so the id maps to exactly one hunk","Select the individual hunks instead of the ambiguous parent id"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-resolve and require exactly one match before selecting:\nlet cli_ids = id_map.parse_using_context(&raw_id, ctx)?;\nif cli_ids.len() != 1 {\n    // ambiguous or missing: re-list and ask for a narrower id instead of proceeding\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always require len() == 1 when resolving selection ids","Do not cache ids across diff-context or split-setting changes","Prefer the most specific id form the listing provides"],"tags":["diff","hunk","ambiguous-id","selection"],"backgroundTag":"ambiguous-identifier","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}