{"record":{"id":"9df375607b996d8a","repo":"nikivdev/code","slug":"failed-to-restore-sync-auto-stash-automatically-9df375","errorCode":null,"errorMessage":"failed to restore sync auto-stash automatically: {}\nRun `git stash list` and restore manually if needed.","messagePattern":"failed to restore sync auto-stash automatically: (.+?)\nRun `git stash list` and restore manually if needed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sync.rs","lineNumber":5258,"sourceCode":"                    }\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 {\n    output.contains(\"could not restore untracked files from stash\")\n        || (output.contains(\"already exists, no checkout\") && output.contains(\"stash\"))\n}\n\nfn drop_stash_if_untracked_restored(repo_root: &Path) -> Result<bool> {\n    if git_capture_in(repo_root, &[\"rev-parse\", \"--verify\", \"stash@{0}\"]).is_err() {","sourceCodeStart":5240,"sourceCodeEnd":5276,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sync.rs#L5240-L5276","documentation":"Auto-stash restore failed with a captured git `detail`, but no repair packet path exists, so only manual `git stash list` recovery is suggested. This is the fallback bail at the end of the restore helper.","triggerScenarios":"Stash pop/apply failed (detail recorded) and `repair_packet_path` is None; all packet-less fallbacks exhausted.","commonSituations":"Simple conflict on pop in a one-off sync run; stash entry locked or corrupted; repo dirty in ways stash apply rejects.","solutions":["Read `detail` for the exact git error","`git stash list` then `git stash apply stash@{0}`, resolve conflicts, `git stash drop`","Re-run sync with autofix/repair enabled to get a repair packet next time"],"exampleFix":"git stash apply stash@{0}\n# resolve conflicts\ngit add -A && git stash drop stash@{0}","handlingStrategy":"fallback","validationCode":"git status --porcelain  # refuse to sync with dirty tree\n# abort if output non-empty","typeGuard":null,"tryCatchPattern":"match sync() {\n    Err(e) if e.contains(\"failed to restore sync auto-stash\") => {\n        run(\"git\", &[\"stash\", \"list\"]);\n        run(\"git\", &[\"stash\", \"apply\", \"stash@{0}\"]);\n        // resolve, then stash drop\n    }\n    other => other,\n}","preventionTips":["Commit local work before syncing so nothing needs a stash","Keep autofix/repair-packet features enabled for automatic recovery","Check `git stash list` after any failed sync — entries may persist","Avoid running other git commands concurrently with sync"],"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"}