gitbutlerapp/gitbutler · error
Two conflicted paths normalize to the same value
Error message
Two conflicted paths normalize to the same value ({:?}); resolve this commit manually instead What it means
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.
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
Example fix
// before files: ["src/a.rs".into(), "./src/a.rs".into()] // after files: ["src/a.rs".into()] // deduplicated after normalization
Defensive patterns
Strategy: validation
Validate before calling
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'); Try / catch
try { await applySpecs(specs); } catch (e) { if (String(e).includes('normalize to the same value')) { /* dedupe request files */ } else { throw e; } } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Aborting due to empty branch name
- Aborting due to empty
- API returned version
- At least one review number is required
- Branch name ' ' collides with existing branch
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/7d18c93483827c4c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-api/src/resolve/apply.rs:141
file.hunks.len(),
if file.hunks.len() == 1 { "" } else { "s" },
hunk
);
}
Ok((file_index, hunk - 1))
}
/// Map normalized request paths to file indices, rejecting collisions.
pub(crate) fn index_files_by_path(
request: &ResolutionRequest,
) -> anyhow::Result<BTreeMap<String, usize>> {
let mut files_by_path = BTreeMap::new();
for (index, file) in request.files.iter().enumerate() {
if files_by_path
.insert(normalize_path(&file.path), index)
.is_some()
{
bail!(
"Two conflicted paths normalize to the same value ({:?}); resolve this commit manually instead",
normalize_path(&file.path)
);
}
}
Ok(files_by_path)
}
/// Reject content that contains a conflict-marker-shaped line.
pub(crate) fn ensure_no_markers(content: &str, path: &str) -> anyhow::Result<()> {
if let Some(marker) = content
.lines()
.map(|line| line.strip_suffix('\r').unwrap_or(line))
.find(|line| is_marker_shaped(line))
{
bail!("The resolution for \"{path}\" contains a conflict marker ({marker:?})");
}
Ok(())View on GitHub (pinned to 58e5313667)