gitbutlerapp/gitbutler · error
'{raw_id}' resolved to more than one hunk ({})
Error message
'{raw_id}' resolved to more than one hunk ({}) What it means
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.
Source
Thrown at crates/but/src/utils/diff_rendering.rs:1163
ctx: &'a Context,
id_map: &'a IdMap,
mut filter: F,
) -> anyhow::Result<Vec<(&'a str, Arc<CliId>, &'a UncommittedHunk)>>
where
F: FnMut(&but_core::SingleHunk) -> bool,
{
let mut uncommitted_hunks = id_map
.uncommitted_hunks
.iter()
.filter(move |(_, hunk)| filter(&hunk.hunk))
.map(|(raw_id, hunk)| {
let mut cli_ids = id_map.parse_using_context(raw_id, ctx)?;
if cli_ids.len() == 1 {
Ok((&**raw_id, Arc::new(cli_ids.remove(0)), hunk))
} else if cli_ids.is_empty() {
bail!("'{raw_id}' no found")
} else {
bail!(
"'{raw_id}' resolved to more than one hunk ({})",
cli_ids.len()
)
}
})
.collect::<anyhow::Result<Vec<_>>>()?;
uncommitted_hunks.sort_by(|(id_a, _, hunk_a), (id_b, _, hunk_b)| {
(
&hunk_a.hunk.path,
hunk_a
.hunk
.hunk_header
.as_ref()
.map(|header| header.old_start),
id_a,
)
.cmp(&(View on GitHub (pinned to caf1f223d3)
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
Defensive patterns
Strategy: validation
Validate before calling
// pre-resolve and require exactly one match before selecting:
let cli_ids = id_map.parse_using_context(&raw_id, ctx)?;
if cli_ids.len() != 1 {
// ambiguous or missing: re-list and ask for a narrower id instead of proceeding
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Changing diff context settings between listing and selection, tools that collapse/expand hunks, programmatic callers passing aggregate ids.
Related errors
- '{raw_id}' no found
- Cannot compute diff specs for branch `{}`
- Failed to communicate with LM Studio server: ${error instanc
- When using LM Studio, you must provide a valid endpoint
- Commit {} is not in the applied workspace
AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20).
Data as JSON: /api/errors/6b18661a05236d10.
Report an issue: GitHub.