{"record":{"id":"4bd6fe6d0924ffee","repo":"Hmbown/CodeWhale","slug":"failed-to-persist-turn-persistence-error","errorCode":null,"errorMessage":"Failed to persist turn: {persistence_error}","messagePattern":"Failed to persist turn: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/runtime_threads.rs","lineNumber":6146,"sourceCode":"            state.route_identity = provider_identity;\n            state.route_model.clone_from(&model);\n\n            let persistence_result = (|| -> Result<()> {\n                self.store.save_item(&user_item)?;\n                self.store.save_turn(&turn)?;\n                current_thread.latest_turn_id = Some(turn_id.clone());\n                current_thread.updated_at = now;\n                self.store.save_thread(&current_thread)\n            })();\n            if let Err(persistence_error) = persistence_result {\n                let cleanup_error = self\n                    .cleanup_unaccepted_turn_records(&turn_id, Some(&user_item_id))\n                    .err();\n                state.active_turn = None;\n                state.route_identity = previous_active_route.0;\n                state.route_model = previous_active_route.1;\n                return match cleanup_error {\n                    None => Err(anyhow!(\"Failed to persist turn: {persistence_error}\")),\n                    Some(cleanup_error) => Err(anyhow!(\n                        \"Failed to persist turn: {persistence_error}; cleanup also failed: {cleanup_error}\"\n                    )),\n                };\n            }\n\n            self.register_runtime_usage_sink(&turn_id);\n            // Sending through an owned permit cannot await or fail. From this\n            // point the engine owns the operation and the spawned task owns\n            // lifecycle events, monitoring, and terminal cleanup even if the\n            // HTTP/client future is dropped.\n            engine.publish_turn_authority(\n                mode,\n                allow_shell,\n                trust_mode,\n                auto_approve,\n                policy.permission,\n                configured_sandbox_mode,","sourceCodeStart":6128,"sourceCodeEnd":6164,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/runtime_threads.rs#L6128-L6164","documentation":"Saving the accepted turn's durable state (user item, turn, thread) failed partway; the code then attempts cleanup of the unaccepted turn so memory and disk stay consistent, and surfaces the persistence error with the cleanup outcome.","triggerScenarios":"Thrown at crates/tui/src/runtime_threads.rs:6146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and store write permissions","Verify the thread store location is writable and not locked","Retry the turn after fixing the storage issue"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}