openai/codex · error · anyhow::Error
failed to move damaged sqlite state database files into a…
Error message
failed to move damaged sqlite state database files into a backup folder: {backup_err}; original error: {original_error} What it means
Raised in the sqlite state-db corruption recovery path when the attempt to move the damaged database files into a backup folder fails (backup_err, e.g. permission denied or file locked by another process). Because the damaged files could not be moved aside, the runtime cannot safely rebuild the database, so the failure is reported together with the original corruption error (original_error) that triggered recovery.
Solutions
- Check filesystem permissions and free space on the directory holding the state database
- Ensure no other codex process holds the database files open or locked
- Manually move or delete the damaged database files, then restart so init can rebuild from scratch
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at codex-rs/app-server/src/lib.rs:1279 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/b881eb031a4da35c.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/app-server/src/lib.rs:1279
{
return Err(err);
}
if !attempted_backups.insert(database_path.clone()) {
return Err(anyhow::anyhow!(
"failed to initialize sqlite state runtime after moving damaged database file into a backup folder: {err}"
));
}
let original_error = err.to_string();
emit_state_db_backup_warning(&format!(
"Codex local database at {} appears damaged. Moving it into a backup folder so the app server can rebuild it from saved data.",
database_path.display()
));
let backups = codex_state::backup_runtime_db_for_fresh_start(database_path.as_path())
.await
.map_err(|backup_err| {
anyhow::anyhow!(
"failed to move damaged sqlite state database files into a backup folder: {backup_err}; original error: {original_error}"
)
})?;
for backup in &backups {
emit_state_db_backup_warning(&format!(
"Moved damaged Codex local database file {} to {}",
backup.original_path.display(),
backup.backup_path.display()
));
}
if let Some(first_backup) = backups.first()
&& let Some(backup_folder) = first_backup.backup_path.parent()
{
recovered_databases.push(RecoveredSqliteDatabase {
database_path: first_backup.original_path.display().to_string(),
backup_folder: backup_folder.display().to_string(),
});
}View on GitHub (pinned to 339751715c)