gitbutlerapp/gitbutler · critical
Database file at ' has corrupted copies - giving up…
Error message
Database file at '{db_path} has {max_attempts} corrupted copies - giving up, application probably won't work What it means
assure_database_valid in the Tauri project handler verifies the project's SQLite database can be opened. When the file is corrupt it is backed up and recreated, retrying up to max_attempts times; if every attempt still yields a corrupt database, it bails with this fatal message because the application cannot function without a working project database.
Solutions
- Check free disk space and fix underlying I/O problems (full disk, failing drive, AV/sync interference)
- Look for the .bak/recovery copies next to the db path; inspect them to recover data, then close all GitButler processes and restart
- Delete the corrupted db file(s) so a clean database can be created (project metadata will be re-derived from git)
- If it persists, run sqlite3 integrity checks / update SQLite and report with logs
Defensive patterns
Strategy: try-catch
Validate before calling
// before activating a project
let db_path = project.db_path();
if !db_path.parent().map(|p| p.writable()).unwrap_or(false) { /* alert user: db dir not writable */ }
// check free space and that db_path is not a directory Try / catch
match result {
Err(e) if e.to_string().contains("corrupted copies") => {
// show fatal dialog: advise closing app, freeing disk space,
// and restoring the *.bak db copies next to db_path
}
r => r?,
} Prevention
- Don't place project dbs inside synced folders (Dropbox/OneDrive)
- Ensure clean shutdown; avoid killing the app mid-write
- Monitor disk space before large operations
- Back up the project db periodically
When it happens
Trigger: Opening/activating a project whose sqlite file is corrupt; the repair loop (move corrupt file to backup, recreate) has already run max_attempts times and each freshly created copy is still unreadable.
Common situations: Disk full or I/O errors during writes, abrupt process kill mid-write leaving a corrupt WAL/journal, antivirus or sync tools (Dropbox/OneDrive) locking or mangling the db file, failing disk, or db path pointing at a directory/locked file so every new copy fails too.
Related errors
- Failed to persist action
- Failed to list actions
- Failed to rename to - application may fail to startup
- Failed to parse branch_ref_bytes
- Failed to serialize hunk_header
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/2678a2279c1fdbf7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-tauri/src/projects.rs:156
if backup_path.is_file() {
continue;
}
if let Err(err) = std::fs::rename(&db_path, &backup_path) {
bail!(
"Failed to rename {} to {} - application may fail to startup: {err}",
db_path.display(),
backup_path.display()
);
}
return Ok(Some(format!(
"Could not open db file at '{}'.\nIt was moved to {} for recovery. \n\nError was: {err}",
db_path.display(),
backup_path.display()
)));
}
bail!(
"Database file at '{db_path} has {max_attempts} corrupted copies - giving up, application probably won't work",
db_path = db_path.display()
);
}
Ok(None)
}
/// Return an error message that
fn warn_about_filters_and_git_lfs(repo: &gix::Repository) -> anyhow::Result<Option<String>> {
let index = repo.index_or_empty()?;
let mut cache = repo.attributes_only(
&index,
gix::worktree::stack::state::attributes::Source::WorktreeThenIdMapping,
)?;
let mut attrs = cache.selected_attribute_matches(Some("filter"));
let mut all_filters = BTreeSet::<String>::new();
let mut files_with_filter = Vec::new();
for entry in index.entries() {View on GitHub (pinned to 58e5313667)