{"record":{"id":"2f9a5c05240e3948","repo":"gitbutlerapp/gitbutler","slug":"has-conflict-but-conflict-was-addres","errorCode":null,"errorMessage":"\"{}\" has {} conflict{}, but conflict {} was addressed","messagePattern":"\"(.+?)\" has (.+?) conflict(.+?), but conflict (.+?) was addressed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/resolve/apply.rs","lineNumber":120,"sourceCode":"            // Naming the reason matters here: the file *is* conflicted, it just\n            // has no hunks to address, so \"not a conflicted file\" would read as\n            // a caller mistake rather than a property of the conflict.\n            let normalized = normalize_path(path);\n            match request\n                .manual\n                .iter()\n                .find(|file| normalize_path(&file.path) == normalized)\n            {\n                Some(file) => format!(\n                    \"\\\"{path}\\\" cannot be resolved this way: {} Resolve this commit in edit mode instead.\",\n                    file.reason\n                ),\n                None => format!(\"\\\"{path}\\\" is not a conflicted file of this commit\"),\n            }\n        })?;\n    let file = &request.files[file_index];\n    if hunk == 0 || hunk > file.hunks.len() {\n        bail!(\n            \"\\\"{}\\\" has {} conflict{}, but conflict {} was addressed\",\n            file.path,\n            file.hunks.len(),\n            if file.hunks.len() == 1 { \"\" } else { \"s\" },\n            hunk\n        );\n    }\n    Ok((file_index, hunk - 1))\n}\n\n/// Map normalized request paths to file indices, rejecting collisions.\npub(crate) fn index_files_by_path(\n    request: &ResolutionRequest,\n) -> anyhow::Result<BTreeMap<String, usize>> {\n    let mut files_by_path = BTreeMap::new();\n    for (index, file) in request.files.iter().enumerate() {\n        if files_by_path\n            .insert(normalize_path(&file.path), index)","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/resolve/apply.rs#L102-L138","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nresolve(hunk: 0) // invalid: 1-based\n// after\nif hunk >= 1 && hunk <= file.hunks.len() { resolve(hunk) }","handlingStrategy":"validation","validationCode":"if (hunk < 1 || hunk > file.hunks.length) throw new Error(`conflict ${hunk} out of range for ${file.path}`);","typeGuard":null,"tryCatchPattern":"try { await applySpecs(specs); } catch (e) { if (String(e).includes('but conflict') && String(e).includes('was addressed')) { await refreshConflicts(); /* rebuild specs */ } else { throw e; } }","preventionTips":["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"],"tags":["validation","index-out-of-range","merge-conflict"],"backgroundTag":"value-out-of-range","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"}