gitbutlerapp/gitbutler · error

Conflict of " " was addressed more than once

Error message

Conflict {} of "{}" was addressed more than once

What it means

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.

Solutions

  1. Deduplicate specs by (file path, hunk index) before submitting
  2. Ensure AI-generated specs are materialized exactly once via resolve_ai_specs
  3. Check hunk indices are 1-based and unique per file in the client payload

Example fix

// before
specs.push(hunk_spec(0)); specs.push(hunk_spec(0)); // same conflict twice
// after
let seen: HashSet<usize> = HashSet::new();
if seen.insert(hunk_index) { specs.push(hunk_spec(hunk_index)); }
Defensive patterns

Strategy: validation

Validate before calling

const seen = new Set(specs.map(s => `${s.file}:${s.hunk}`)); if (seen.size !== specs.length) throw new Error('duplicate conflict addressed');

Try / catch

try { await applySpecs(specs); } catch (e) { if (String(e).includes('was addressed more than once')) { specs = dedupeSpecs(specs); await applySpecs(specs); } else { throw e; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/33235e24474a8c9b. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-api/src/resolve/apply.rs:80

) -> anyhow::Result<PicksPerFile> {
    let files_by_path = index_files_by_path(request)?;
    let mut picks: PicksPerFile = vec![BTreeMap::new(); request.files.len()];

    for spec in specs {
        let (file_index, hunk_index) = locate_hunk(request, &files_by_path, &spec.path, spec.hunk)?;
        let file = &request.files[file_index];
        let pick = match &spec.resolution {
            HunkResolution::Ours => HunkPick::Ours,
            HunkResolution::Theirs => HunkPick::Theirs,
            HunkResolution::Content(content) => {
                ensure_no_markers(content, &file.path)?;
                HunkPick::Content(content.clone())
            }
            // Replaced with `Content` by `resolve_ai_specs()` before validation.
            HunkResolution::Ai => bail!("AI resolutions must be materialized before validation"),
        };
        if picks[file_index].insert(hunk_index, pick).is_some() {
            bail!(
                "Conflict {} of \"{}\" was addressed more than once",
                spec.hunk,
                file.path
            );
        }
    }

    Ok(picks)
}

/// Resolve a `(path, 1-based hunk)` address against the request, returning
/// the file index and 0-based hunk index.
pub(crate) fn locate_hunk(
    request: &ResolutionRequest,
    files_by_path: &BTreeMap<String, usize>,
    path: &str,
    hunk: usize,
) -> anyhow::Result<(usize, usize)> {

View on GitHub (pinned to 58e5313667)