{"record":{"id":"aebda9c923db8416","repo":"gitbutlerapp/gitbutler","slug":"failed-to-persist-action-e","errorCode":null,"errorMessage":"Failed to persist action: {e}","messagePattern":"Failed to persist action: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-action/src/action.rs","lineNumber":152,"sourceCode":"        Self {\n            id: Uuid::new_v4(),\n            created_at: chrono::Local::now().naive_local(),\n            handler,\n            external_prompt,\n            external_summary,\n            snapshot_before,\n            snapshot_after,\n            response: rsp.cloned(),\n            error,\n            source,\n        }\n    }\n}\n\nfn persist_action(db: &mut DbHandle, action: ButlerAction) -> anyhow::Result<()> {\n    db.butler_actions_mut()\n        .insert(action.try_into()?)\n        .map_err(|e| anyhow::anyhow!(\"Failed to persist action: {e}\"))?;\n    Ok(())\n}\n\n/// Persist a completed handle-changes action record and return its generated ID.\n///\n/// `db` is the already-open project database handle to write into. `change_summary`,\n/// `external_prompt`, `handler`, and `source` describe the request that produced the action.\n/// `snapshot_before` and `snapshot_after` link the action to the surrounding oplog snapshots.\n/// `response` is stored as either the successful action outcome or the error text.\n#[expect(clippy::too_many_arguments)]\npub(crate) fn record_handle_changes_action(\n    db: &mut DbHandle,\n    change_summary: &str,\n    external_prompt: Option<String>,\n    handler: crate::ActionHandler,\n    source: Source,\n    snapshot_before: gix::ObjectId,\n    snapshot_after: gix::ObjectId,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-action/src/action.rs#L134-L170","documentation":"persist_action writes a ButlerAction into the project database via db.butler_actions_mut().insert(). Any error from the insert (constraint violation, SQL failure, conversion error surfaced by try_into) is wrapped as 'Failed to persist action: {e}'.","triggerScenarios":"record_handle_changes_action calls persist_action and the underlying insert into butler_actions returns Err — e.g. db locked, constraint failure, or the action fails TryInto for storage.","commonSituations":"Database locked by another connection while the app is busy; disk full; schema mismatch after app upgrade; record too large or violating a NOT NULL/UNIQUE constraint.","solutions":["Read the inner error '{e}' from the message to identify the SQL-level cause and fix accordingly","Ensure no other process/connection holds the project db locked; retry the action","Check disk space and db file permissions","Verify the db schema matches the app version (migrations ran); rebuild the db if corrupt"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before persisting\nensure!(db.ping().is_ok(), \"db unavailable\");\nensure!(available_space(&db_path)? > min_needed, \"low disk\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = persist_action(db, action) {\n  log::error!(\"{e:#}\");\n  // inspect inner '{e}' for constraint/lock cause; retry once on lock errors\n}","preventionTips":["Serialize db writes through one connection","Run migrations on startup so schema matches","Monitor disk space","Don't persist actions inside long transactions that can deadlock"],"tags":["database","sqlite","persistence","write"],"backgroundTag":"database-write-failed","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}