nikivdev/code · error
sync agent cleared the raw stash conflicts but left the repo
Error message
sync agent cleared the raw stash conflicts but left the repo mid-merge.
Run `:sync repair --packet {}` or inspect the repo before dropping the stash. What it means
The automated repair agent (Claude-driven repair route) reported it cleared the raw stash conflict markers but the repository is still in a mid-merge state (MERGE_HEAD present / unresolved index entries). The library bails so the user does not drop a stash from a half-finished merge.
Source
Thrown at src/sync.rs:5244
}
if let Some(packet_path) = repair_packet_path {
if allow_autofix {
match try_route_sync_conflicts_to_sync_agent(repo_root, &packet_path)? {
SyncRepairRouteOutcome::Completed => {
restore_intent_to_add_paths(repo_root, &auto_stash_state.intent_to_add_paths)
.context("restored stash but could not restore intent-to-add markers")?;
if drop_latest_stash_if_present(repo_root)? {
sync_progressln!(
" ✓ Sync agent resolved stash conflicts and dropped auto-stash"
);
} else {
sync_progressln!(" ✓ Sync agent resolved stash conflicts");
}
return Ok(());
}
SyncRepairRouteOutcome::ValidationPending => {
bail!(
"sync agent cleared the raw stash conflicts but left the repo mid-merge.\nRun `:sync repair --packet {}` or inspect the repo before dropping the stash.",
packet_path.display()
);
}
SyncRepairRouteOutcome::Unresolved => {}
}
}
bail!(
"failed to restore sync auto-stash automatically: {}\nRun `:sync repair --packet {}` or `git stash list` and restore manually if needed.",
detail,
packet_path.display()
);
}
bail!(
"failed to restore sync auto-stash automatically: {}\nRun `git stash list` and restore manually if needed.",
detail
);
}View on GitHub (pinned to a747e741ae)
Solutions
- Run `:sync repair --packet <path>` to restart the repair flow
- Inspect the repo: `git status`, finish or abort the merge (`git merge --abort` if unintended)
- After verifying the worktree, manually drop the stash entry
Example fix
git status # confirm mid-merge git add -A && git commit # or: git merge --abort :sync repair --packet /tmp/sync-repair-abc123
Defensive patterns
Strategy: validation
Validate before calling
test mid_merge() {
let dirty = std::path::Path::new(".git/MERGE_HEAD").exists();
assert!(!dirty, "resolve mid-merge state before dropping stash");
} Try / catch
if err.contains("left the repo mid-merge") {
// abort or complete the merge before any stash drop
run("git", &["status"]);
// choose: git merge --abort OR git add -A && git commit
} Prevention
- Never `git stash drop` while `.git/MERGE_HEAD` exists
- After any conflict resolution, always `git add` and verify `git status` is clean
- Review agent-produced resolution output instead of trusting success lines
- Keep the repair packet path until the repo is verified clean
When it happens
Trigger: `SyncRepairRouteOutcome::ValidationPending` returned after the agent pass: stash conflicts were edited but post-repair validation still detects merge state.
Common situations: Agent removed conflict markers from files but never ran `git add`; merge was never committed; leftover MERGE_HEAD from the failed stash pop.
Related errors
- failed to stash working tree: {}
- Git index lock detected during merge. Remove stale .git/inde
- git merge --ff-only {} failed: {}
- failed to restore sync auto-stash automatically. Run `:sync
- failed to restore sync auto-stash automatically. Run `git st
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/61ee560e609250b4.
Report an issue: GitHub.