gitbutlerapp/gitbutler · error
" " has conflict , but conflict was addressed
Error message
"{}" has {} conflict{}, but conflict {} was addressed What it means
The requested conflict number does not exist in the conflicted file: it is either 0 or greater than the number of hunks the file actually has. The library validates that each addressed conflict index is in range before applying resolutions.
Solutions
- Re-fetch the conflict file's hunk list and rebuild specs with valid 1-based indices
- Clamp/check hunk index against file.hunks.len() client-side before submitting
- If hunks changed, re-run conflict detection and regenerate resolutions
Example fix
// before
resolve(hunk: 0) // invalid: 1-based
// after
if hunk >= 1 && hunk <= file.hunks.len() { resolve(hunk) } Defensive patterns
Strategy: validation
Validate before calling
if (hunk < 1 || hunk > file.hunks.length) throw new Error(`conflict ${hunk} out of range for ${file.path}`); Try / catch
try { await applySpecs(specs); } catch (e) { if (String(e).includes('but conflict') && String(e).includes('was addressed')) { await refreshConflicts(); /* rebuild specs */ } else { throw e; } } Prevention
- Always fetch fresh conflict file state before building specs
- Use 1-based hunk indices consistently
- Rebuild specs after any rebase/merge that changes conflict content
When it happens
Trigger: locate_hunk (called from validate_specs) receives a spec whose hunk index is 0, negative-equivalent, or larger than file.hunks.len() for the named conflicted file.
Common situations: Stale specs computed against an older version of the conflict file (hunks changed after a rebase/re-merge), 0-based vs 1-based indexing mix-ups, or specs referencing a file whose conflict count shrank.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Conflict of " " was addressed more than once
- The resolution for " " contains a conflict marker ( )
- Validation
- Aborting due to empty branch name
- Aborting due to empty
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/2f9a5c05240e3948.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/resolve/apply.rs:120
// Naming the reason matters here: the file *is* conflicted, it just
// has no hunks to address, so "not a conflicted file" would read as
// a caller mistake rather than a property of the conflict.
let normalized = normalize_path(path);
match request
.manual
.iter()
.find(|file| normalize_path(&file.path) == normalized)
{
Some(file) => format!(
"\"{path}\" cannot be resolved this way: {} Resolve this commit in edit mode instead.",
file.reason
),
None => format!("\"{path}\" is not a conflicted file of this commit"),
}
})?;
let file = &request.files[file_index];
if hunk == 0 || hunk > file.hunks.len() {
bail!(
"\"{}\" has {} conflict{}, but conflict {} was addressed",
file.path,
file.hunks.len(),
if file.hunks.len() == 1 { "" } else { "s" },
hunk
);
}
Ok((file_index, hunk - 1))
}
/// Map normalized request paths to file indices, rejecting collisions.
pub(crate) fn index_files_by_path(
request: &ResolutionRequest,
) -> anyhow::Result<BTreeMap<String, usize>> {
let mut files_by_path = BTreeMap::new();
for (index, file) in request.files.iter().enumerate() {
if files_by_path
.insert(normalize_path(&file.path), index)View on GitHub (pinned to 58e5313667)