gitbutlerapp/gitbutler · error

The model returned more than one resolution for

Error message

The model returned more than one resolution for "{}"

What it means

`validate_ai_response` rejects responses containing two resolutions for the same conflicted file. Each requested file may be resolved at most once; a duplicate means ambiguous content to apply, so validation fails.

Solutions

  1. Deduplicate resolutions by normalized path before submitting/validating, keeping the last or best entry
  2. Instruct the model to emit exactly one resolution per conflicted file and validate with a schema that enforces uniqueness
  3. Retry the request once if the API's single retry does not clear it

Example fix

// before
const resolutions = [...partial, ...full]; // same path twice
// after
const unique = new Map(resolutions.map(r => [normalizePath(r.path), r]));
response.resolutions = [...unique.values()];
Defensive patterns

Strategy: validation

Validate before calling

const seen = new Set();
for (const r of response.resolutions) {
  const k = normalizePath(r.path);
  if (seen.has(k)) throw new Error('duplicate resolution for ' + r.path);
  seen.add(k);
}

Type guard

null

Try / catch

try {
  await api.resolveCommitConflictsWith(ctx, commitId, specs);
} catch (e) {
  if (e.message.includes('more than one resolution')) dedupeAndRetryOnce();
}

Prevention

When it happens

Trigger: An AI model returns a `response.resolutions` array with two entries whose normalized `path` maps to the same index in `request.files`, when passed through `resolve_ai_specs` or `resolve_commit_conflicts_with`.

Common situations: The model emits one resolution per hunk-group plus a whole-file resolution; prompt changes cause duplicated JSON objects; a retried request's outputs are concatenated.

Related errors


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

Appendix: source

Thrown at crates/but-api/src/resolve/mod.rs:625

/// full-coverage picks plus the per-file display payload. Any mismatch fails
/// validation so the caller can retry the model once before giving up.
fn validate_ai_response(
    request: &ResolutionRequest,
    response: &ResolutionResponse,
) -> anyhow::Result<(apply::PicksPerFile, Vec<ResolvedFile>)> {
    let files_by_path = apply::index_files_by_path(request)?;
    let mut picks: apply::PicksPerFile = vec![BTreeMap::new(); request.files.len()];
    let mut resolved_files: Vec<Option<ResolvedFile>> = vec![None; request.files.len()];

    for resolution in &response.resolutions {
        let Some(&index) = files_by_path.get(&apply::normalize_path(&resolution.path)) else {
            bail!(
                "The model returned a resolution for \"{}\", which was not requested",
                resolution.path
            );
        };
        if resolved_files[index].is_some() {
            bail!(
                "The model returned more than one resolution for \"{}\"",
                resolution.path
            );
        }
        let file = &request.files[index];
        if resolution.hunks.len() != file.hunks.len() {
            bail!(
                "The model returned {} resolved hunks for \"{}\" but the file has {} conflicts",
                resolution.hunks.len(),
                file.path,
                file.hunks.len()
            );
        }
        if resolution.reasoning.trim().is_empty() {
            bail!("The model returned no reasoning for \"{}\"", file.path);
        }
        for (hunk_index, hunk) in resolution.hunks.iter().enumerate() {
            apply::ensure_no_markers(&hunk.resolved_content, &file.path)?;

View on GitHub (pinned to 58e5313667)