{"record":{"id":"33235e24474a8c9b","repo":"gitbutlerapp/gitbutler","slug":"conflict-of-was-addressed-more-than-once","errorCode":null,"errorMessage":"Conflict {} of \"{}\" was addressed more than once","messagePattern":"Conflict (.+?) of \"(.+?)\" was addressed more than once","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/resolve/apply.rs","lineNumber":80,"sourceCode":") -> anyhow::Result<PicksPerFile> {\n    let files_by_path = index_files_by_path(request)?;\n    let mut picks: PicksPerFile = vec![BTreeMap::new(); request.files.len()];\n\n    for spec in specs {\n        let (file_index, hunk_index) = locate_hunk(request, &files_by_path, &spec.path, spec.hunk)?;\n        let file = &request.files[file_index];\n        let pick = match &spec.resolution {\n            HunkResolution::Ours => HunkPick::Ours,\n            HunkResolution::Theirs => HunkPick::Theirs,\n            HunkResolution::Content(content) => {\n                ensure_no_markers(content, &file.path)?;\n                HunkPick::Content(content.clone())\n            }\n            // Replaced with `Content` by `resolve_ai_specs()` before validation.\n            HunkResolution::Ai => bail!(\"AI resolutions must be materialized before validation\"),\n        };\n        if picks[file_index].insert(hunk_index, pick).is_some() {\n            bail!(\n                \"Conflict {} of \\\"{}\\\" was addressed more than once\",\n                spec.hunk,\n                file.path\n            );\n        }\n    }\n\n    Ok(picks)\n}\n\n/// Resolve a `(path, 1-based hunk)` address against the request, returning\n/// the file index and 0-based hunk index.\npub(crate) fn locate_hunk(\n    request: &ResolutionRequest,\n    files_by_path: &BTreeMap<String, usize>,\n    path: &str,\n    hunk: usize,\n) -> anyhow::Result<(usize, usize)> {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/resolve/apply.rs#L62-L98","documentation":"During validation of AI/hunk resolution specs, each conflict (identified by hunk index within a file) may only be addressed once. A duplicate insert into the per-file hunk map means the caller submitted two specs touching the same conflict, which is ambiguous, so validation fails.","triggerScenarios":"Calling validate_specs (via specs_translate_side_picks_and_content or specs_are_validated) with a specs list containing two entries whose (file, hunk) pair collides — e.g. both a side pick and a content resolution for the same conflict hunk.","commonSituations":"Clients applying an AI resolution and then also manually submitting a resolution for the same conflict, re-sending a batch that already includes one spec, or off-by-one hunk numbering merging two distinct conflicts into one index.","solutions":["Deduplicate specs by (file path, hunk index) before submitting","Ensure AI-generated specs are materialized exactly once via resolve_ai_specs","Check hunk indices are 1-based and unique per file in the client payload"],"exampleFix":"// before\nspecs.push(hunk_spec(0)); specs.push(hunk_spec(0)); // same conflict twice\n// after\nlet seen: HashSet<usize> = HashSet::new();\nif seen.insert(hunk_index) { specs.push(hunk_spec(hunk_index)); }","handlingStrategy":"validation","validationCode":"const seen = new Set(specs.map(s => `${s.file}:${s.hunk}`)); if (seen.size !== specs.length) throw new Error('duplicate conflict addressed');","typeGuard":null,"tryCatchPattern":"try { await applySpecs(specs); } catch (e) { if (String(e).includes('was addressed more than once')) { specs = dedupeSpecs(specs); await applySpecs(specs); } else { throw e; } }","preventionTips":["Deduplicate specs by (file, hunk) before submission","Never mix AI-materialized and manual specs for the same hunk","Track hunk numbering carefully (1-based)"],"tags":["validation","duplicate-spec","merge-conflict"],"backgroundTag":"conflicting-config-options","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"}