{"record":{"id":"7d18c93483827c4c","repo":"gitbutlerapp/gitbutler","slug":"two-conflicted-paths-normalize-to-the-same-value","errorCode":null,"errorMessage":"Two conflicted paths normalize to the same value ({:?}); resolve this commit manually instead","messagePattern":"Two conflicted paths normalize to the same value \\((.+?)\\); resolve this commit manually instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/resolve/apply.rs","lineNumber":141,"sourceCode":"            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)\n            .is_some()\n        {\n            bail!(\n                \"Two conflicted paths normalize to the same value ({:?}); resolve this commit manually instead\",\n                normalize_path(&file.path)\n            );\n        }\n    }\n    Ok(files_by_path)\n}\n\n/// Reject content that contains a conflict-marker-shaped line.\npub(crate) fn ensure_no_markers(content: &str, path: &str) -> anyhow::Result<()> {\n    if let Some(marker) = content\n        .lines()\n        .map(|line| line.strip_suffix('\\r').unwrap_or(line))\n        .find(|line| is_marker_shaped(line))\n    {\n        bail!(\"The resolution for \\\"{path}\\\" contains a conflict marker ({marker:?})\");\n    }\n    Ok(())","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/resolve/apply.rs#L123-L159","documentation":"After normalizing paths (trim, backslash->slash, strip ./, collapse duplicate slashes), two entries in the conflicted-files request resolve to the same key. The lookup map could not disambiguate them, so the library refuses and suggests resolving the commit manually.","triggerScenarios":"index_files_by_path (from validate_specs) receives a request.files list where two different raw paths normalize identically, e.g. \"src/a.rs\" and \"./src//a.rs\", or case/whitespace variants.","commonSituations":"Hand-constructed resolution requests duplicating a file path with cosmetic differences, clients echoing paths from both Windows and POSIX style, or upstream tooling emitting the same file twice.","solutions":["Deduplicate request.files after applying the same normalization the library uses","Send each conflicted path exactly once, as returned by the conflict listing","Manually resolve the commit with git if duplicate conflicted paths are genuine"],"exampleFix":"// before\nfiles: [\"src/a.rs\".into(), \"./src/a.rs\".into()]\n// after\nfiles: [\"src/a.rs\".into()] // deduplicated after normalization","handlingStrategy":"validation","validationCode":"const norm = p => p.trim().replace(/\\\\/g,'/').replace(/^\\.\\//,'').replace(/\\/{2,}/g,'/'); const keys = files.map(f => norm(f.path)); if (new Set(keys).size !== keys.length) throw new Error('duplicate normalized paths');","typeGuard":null,"tryCatchPattern":"try { await applySpecs(specs); } catch (e) { if (String(e).includes('normalize to the same value')) { /* dedupe request files */ } else { throw e; } }","preventionTips":["Send paths exactly as returned by the conflict listing API","Normalize/dedupe paths client-side before building the request","Avoid mixing Windows and POSIX style separators"],"tags":["validation","duplicate-path","path-normalization"],"backgroundTag":"invalid-argument-value","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"}