{"record":{"id":"1e31b6282e8ce7a1","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-rollout-rollback-failed-restore-error","errorCode":null,"errorMessage":"{error}; rollout rollback failed: {restore_error}","messagePattern":"(.+?); rollout rollback failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/codex-plus-data/src/provider_sync.rs","lineNumber":3540,"sourceCode":"            Ok(None) => applied.skipped_locked_rollout_files.push(plan.path.clone()),\n            Err(error) if is_locked_anyhow_error(&error) => {\n                applied.skipped_locked_rollout_files.push(plan.path.clone());\n            }\n            Err(error) => {\n                if !applied.changes.is_empty() {\n                    report_provider_sync_progress(\n                        report_progress,\n                        ProviderSyncProgressPhase::RollingBack,\n                        total_rollout_files,\n                        total_rollout_files,\n                        rewrite_plans.len(),\n                        applied.changes.len(),\n                        scanned_skipped_rollout_files\n                            + applied.skipped_locked_rollout_files.len(),\n                    );\n                }\n                if let Err(restore_error) = restore_bulk_session_rewrites(&applied.changes) {\n                    return Err(anyhow::anyhow!(\n                        \"{error}; rollout rollback failed: {restore_error}\"\n                    ));\n                }\n                return Err(error);\n            }\n        }\n        report_bulk_rewrite_progress(\n            report_progress,\n            total_rollout_files,\n            rewrite_plans.len(),\n            index + 1,\n            applied.changes.len(),\n            scanned_skipped_rollout_files + applied.skipped_locked_rollout_files.len(),\n        );\n    }\n    Ok(applied)\n}\n","sourceCodeStart":3522,"sourceCodeEnd":3558,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-data/src/provider_sync.rs#L3522-L3558","documentation":"During a bulk session (rollout file) rewrite in provider_sync.rs, if applying a change fails, the code attempts to roll back all previously applied writes via restore_bulk_session_rewrites. When that rollback itself fails, this error is raised chaining the original apply error and the rollback error so neither is lost; the files may now be in a partially restored state.","triggerScenarios":"A bulk session rewrite applies N changes, one write fails, and restore_bulk_session_rewrites also fails while undoing earlier changes — e.g. because a rollout file was modified after being rewritten, or a later restore step in the loop errors.","commonSituations":"Rollout files being locked or edited by the Codex client during sync; disk-full or permission errors surfacing mid-rollback; crashes/concurrency corrupting the rewritten_sha256 baseline.","solutions":["Read both chained causes: `{error}` is why apply failed, `{restore_error}` is why rollback failed — fix the rollback cause (permissions, locks, changed files) first","Close any process (Codex client) holding the rollout files, then re-run sync to rebuild consistent state","Restore from the nearest backup taken before the sync; the bulk rewrite keeps pre-images precisely so restores are possible","Re-run the sync with the conflicting sessions skipped to isolate the failing rollout file"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before bulk rewrite: ensure target files are writable and not locked\nfor p in &paths { assert!(p.exists()); assert!(!is_locked(p)); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) => {\n        eprintln!(\"apply failed: {e:#}; check chained rollback cause for the real blocker\");\n        // restore from external backup before retrying\n    }\n    Ok(_) => {}\n}","preventionTips":["Stop the Codex client before bulk session rewrites","Ensure ample disk space and write permissions for all rollout files","Take a backup before bulk operations so a failed rollback is recoverable"],"tags":["rust","rollback","file-io"],"backgroundTag":"file-write-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}