gitbutlerapp/gitbutler · error
Failed to persist action
Error message
Failed to persist action: {e} What it means
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}'.
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
Defensive patterns
Strategy: try-catch
Validate before calling
// before persisting ensure!(db.ping().is_ok(), "db unavailable"); ensure!(available_space(&db_path)? > min_needed, "low disk");
Try / catch
if let Err(e) = persist_action(db, action) {
log::error!("{e:#}");
// inspect inner '{e}' for constraint/lock cause; retry once on lock errors
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Database file at ' has corrupted copies - giving up…
- Failed to list actions
- Failed to rename to - application may fail to startup
- Could not write settings
- Failed to parse branch_ref_bytes
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/aebda9c923db8416.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-action/src/action.rs:152
Self {
id: Uuid::new_v4(),
created_at: chrono::Local::now().naive_local(),
handler,
external_prompt,
external_summary,
snapshot_before,
snapshot_after,
response: rsp.cloned(),
error,
source,
}
}
}
fn persist_action(db: &mut DbHandle, action: ButlerAction) -> anyhow::Result<()> {
db.butler_actions_mut()
.insert(action.try_into()?)
.map_err(|e| anyhow::anyhow!("Failed to persist action: {e}"))?;
Ok(())
}
/// Persist a completed handle-changes action record and return its generated ID.
///
/// `db` is the already-open project database handle to write into. `change_summary`,
/// `external_prompt`, `handler`, and `source` describe the request that produced the action.
/// `snapshot_before` and `snapshot_after` link the action to the surrounding oplog snapshots.
/// `response` is stored as either the successful action outcome or the error text.
#[expect(clippy::too_many_arguments)]
pub(crate) fn record_handle_changes_action(
db: &mut DbHandle,
change_summary: &str,
external_prompt: Option<String>,
handler: crate::ActionHandler,
source: Source,
snapshot_before: gix::ObjectId,
snapshot_after: gix::ObjectId,View on GitHub (pinned to 58e5313667)