{"record":{"id":"9243590fd13066ae","repo":"nikivdev/code","slug":"failed-to-restore-sync-auto-stash-automatically","errorCode":null,"errorMessage":"failed to restore sync auto-stash automatically: {}\nRun `:sync repair --packet {}` or `git stash list` and restore manually if needed.","messagePattern":"failed to restore sync auto-stash automatically: (.+?)\nRun `:sync repair --packet (.+?)` or `git stash list` and restore manually if needed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sync.rs","lineNumber":5252,"sourceCode":"                    if drop_latest_stash_if_present(repo_root)? {\n                        sync_progressln!(\n                            \"  ✓ Sync agent resolved stash conflicts and dropped auto-stash\"\n                        );\n                    } else {\n                        sync_progressln!(\"  ✓ Sync agent resolved stash conflicts\");\n                    }\n                    return Ok(());\n                }\n                SyncRepairRouteOutcome::ValidationPending => {\n                    bail!(\n                        \"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.\",\n                        packet_path.display()\n                    );\n                }\n                SyncRepairRouteOutcome::Unresolved => {}\n            }\n        }\n        bail!(\n            \"failed to restore sync auto-stash automatically: {}\\nRun `:sync repair --packet {}` or `git stash list` and restore manually if needed.\",\n            detail,\n            packet_path.display()\n        );\n    }\n    bail!(\n        \"failed to restore sync auto-stash automatically: {}\\nRun `git stash list` and restore manually if needed.\",\n        detail\n    );\n}\n\nfn restore_stash(repo_root: &Path, auto_stash_state: &AutoStashState, allow_autofix: bool) {\n    if let Err(err) = restore_stash_result(repo_root, auto_stash_state, allow_autofix) {\n        sync_stderrln!(\"warning: {}\", err);\n    }\n}\n\nfn stash_pop_untracked_conflict(output: &str) -> bool {","sourceCodeStart":5234,"sourceCodeEnd":5270,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sync.rs#L5234-L5270","documentation":"Auto-stash restore failed and the underlying git error detail is included (`detail`), with a repair packet path available. The library appends the packet-based repair command and manual stash recovery instructions.","triggerScenarios":"Stash pop/apply returned an error captured in `detail` (e.g. conflict output or exit status), `repair_packet_path` was Some, and no repair route (autofix/agent) succeeded.","commonSituations":"Conflicting changes both stashed and re-modified; stash apply refusing due to untracked file overwrite; agent auto-fix unavailable or declined (`allow_autofix` false).","solutions":["Read the embedded `detail` to see the exact git failure","Run `:sync repair --packet <path>` as printed in the message","Or `git stash apply stash@{0}` manually, resolve conflicts, then drop"],"exampleFix":"# message shows: failed to restore ...: CONFLICT (content): Merge conflict in foo.rs\n:sync repair --packet /tmp/sync-repair-abc123","handlingStrategy":"try-catch","validationCode":"git status --porcelain && git stash list  # know the pre-sync state","typeGuard":null,"tryCatchPattern":"if let Err(e) = sync() {\n    let msg = e.to_string();\n    if msg.contains(\"failed to restore sync auto-stash automatically:\") {\n        eprintln!(\"git detail: {}\", msg); // the embedded detail\n        // run `:sync repair --packet <path>` shown in the message\n    }\n}","preventionTips":["Read the embedded detail before acting — it names the exact conflict","Keep autofix enabled to avoid manual recovery","Sync from a clean tree to make stash restore a no-op","Update the tool: newer versions may resolve known stash-restore edge cases"],"tags":["git","stash","conflict","sync"],"backgroundTag":"git-stash-restore-failed","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}