gitbutlerapp/gitbutler · error
The model returned a resolution for
Error message
The model returned a resolution for "{}", which was not requested What it means
`validate_ai_response` rejects an AI resolution response that references a file path not present in the request. Paths are normalized and looked up in `files_by_path`; an unknown path means the model hallucinated or reformatted a filename, so the whole response is invalid and nothing is applied.
Solutions
- Retry the AI request once (the API already retries invalid responses once) with the exact requested file paths echoed in the prompt
- Normalize the model output paths before validation (trim prefixes, unify separators)
- Constrain the model with a strict JSON schema enumerating the allowed paths
Example fix
// before
resolutions: [{ path: 'src/' + file.path, hunks: [...] }]
// after
resolutions: [{ path: file.path, hunks: [...] }] // path exactly as listed in request.files Defensive patterns
Strategy: validation
Validate before calling
const allowed = new Set(request.files.map(f => normalizePath(f.path)));
for (const r of response.resolutions) {
if (!allowed.has(normalizePath(r.path))) throw new Error('unexpected path: ' + r.path);
} Type guard
const isKnownPath = (p: string, files: ResolvedFile[]) => files.some(f => normalizePath(f.path) === normalizePath(p));
Try / catch
try {
await api.resolveAiSpecs(ctx, commitId, specs);
} catch (e) {
if (e.message.includes('which was not requested')) retryWithPromptReinforcement();
} Prevention
- Echo exact requested paths in the prompt and require verbatim reuse
- Normalize paths (separators, prefixes, casing) before comparing
- Use a JSON schema that enumerates allowed path values
When it happens
Trigger: Calling `resolve_ai_specs` or `resolve_commit_conflicts_with` where the model's response contains a `resolution.path` whose normalized form has no entry in the request's `request.files`.
Common situations: The model invents a path, uses a different separator or casing, adds a repo prefix (e.g. `src/` when the request used a bare name), or resolves a stale commit after the user changed conflicts.
Related errors
- Enter an Anthropic API key
- Enter an OpenAI API key
- is required
- Invalid prompt: must be a non-empty array
- The model returned more than one resolution for
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/e776666c6020f4dc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/resolve/mod.rs:619
);
attempt()
})
}
/// Check the model response against the request and translate it into
/// 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()
);View on GitHub (pinned to 58e5313667)