{"record":{"id":"da13ffefa619f733","repo":"nikivdev/code","slug":"failed-to-restore-sync-auto-stash-automatically-r","errorCode":null,"errorMessage":"failed to restore sync auto-stash automatically. Run `:sync repair --packet {}` or `git stash list` and restore manually if needed.","messagePattern":"failed to restore sync auto-stash automatically\\. Run `: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":5218,"sourceCode":"        }\n    }\n    let repair_packet_path = if conflicted_files.is_empty() {\n        None\n    } else {\n        write_sync_repair_packet(\n            repo_root,\n            SyncRepairKind::StashRestoreConflict,\n            &conflicted_files,\n            detail,\n            None,\n            Some(auto_stash_state),\n            packet_dir_override,\n        )\n        .ok()\n    };\n    if detail.is_empty() {\n        if let Some(packet_path) = repair_packet_path {\n            bail!(\n                \"failed to restore sync auto-stash automatically. Run `:sync repair --packet {}` or `git stash list` and restore manually if needed.\",\n                packet_path.display()\n            );\n        }\n        bail!(\n            \"failed to restore sync auto-stash automatically. Run `git stash list` and restore manually if needed.\"\n        );\n    }\n\n    if let Some(packet_path) = repair_packet_path {\n        if allow_autofix {\n            match try_route_sync_conflicts_to_sync_agent(repo_root, &packet_path)? {\n                SyncRepairRouteOutcome::Completed => {\n                    restore_intent_to_add_paths(repo_root, &auto_stash_state.intent_to_add_paths)\n                        .context(\"restored stash but could not restore intent-to-add markers\")?;\n                    if drop_latest_stash_if_present(repo_root)? {\n                        sync_progressln!(\n                            \"  ✓ Sync agent resolved stash conflicts and dropped auto-stash\"","sourceCodeStart":5200,"sourceCodeEnd":5236,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sync.rs#L5200-L5236","documentation":"This error is thrown by the sync command's auto-stash restore logic when an automatic git stash created before syncing could not be popped/applied back onto the repository. The library includes a repair-packet path so the user can re-run a repair flow; this variant fires when a repair packet path is known and gets embedded in the message.","triggerScenarios":"During sync, a stash restore (e.g. `git stash pop`/`apply`) failed with conflicts or a non-clean state, and `repair_packet_path` was Some, but no repair/agent route could restore the stash automatically.","commonSituations":"Concurrent edits to stashed files during sync; merge conflicts reintroduced on pop; dirty worktree from a failed push/pull; interrupted previous sync leaving a stale stash entry.","solutions":["Run the suggested `:sync repair --packet <path>` command shown in the message","Run `git stash list` and manually apply/drop the stash entry","Resolve conflicts manually, then `git stash drop` the restored entry"],"exampleFix":"// terminal\n:sync repair --packet /tmp/sync-repair-abc123\n# or\ngit stash list && git stash apply stash@{0}","handlingStrategy":"fallback","validationCode":"git stash list && git status --porcelain  # ensure no stale auto-stash / clean tree before :sync","typeGuard":null,"tryCatchPattern":"match sync_result {\n    Err(e) if e.to_string().contains(\"failed to restore sync auto-stash\") => {\n        run(\"git\", &[\"stash\", \"list\"]);\n        // apply or drop stash@{0} manually, then rerun repair\n    }\n    r => r?,\n}","preventionTips":["Commit or stash intentionally before running :sync","Avoid editing files while a sync is in flight","Re-run `:sync repair --packet <path>` promptly rather than making more edits","Keep autofix enabled so repair packets can be consumed automatically"],"tags":["git","stash","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"}