{"record":{"id":"d985e8522a90bbe4","repo":"t8y2/dbx","slug":"sqlite-restore-failed-error","errorCode":null,"errorMessage":"SQLite restore failed: {error}","messagePattern":"SQLite restore failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbx-sqlite-worker/src/runtime.rs","lineNumber":221,"sourceCode":"        if !parent.as_os_str().is_empty() {\n            if let Err(error) = std::fs::create_dir_all(parent) {\n                return WorkerBody::err(error.to_string());\n            }\n        }\n    }\n    match conn.backup(DatabaseName::Main, dest, None) {\n        Ok(()) => WorkerBody::ok(),\n        Err(error) => WorkerBody::err(format!(\"SQLite backup failed: {error}\")),\n    }\n}\n\nfn restore(conn: &mut Connection, src: &str) -> WorkerBody {\n    if src.trim().is_empty() || src.contains('\\0') {\n        return WorkerBody::err(\"Restore source is invalid\");\n    }\n    match conn.restore(DatabaseName::Main, src, None::<fn(_)>) {\n        Ok(()) => WorkerBody::ok(),\n        Err(error) => WorkerBody::err(format!(\"SQLite restore failed: {error}\")),\n    }\n}\n\nfn value_to_json(value: rusqlite::types::ValueRef<'_>, column_decl_type: Option<&str>) -> (serde_json::Value, bool) {\n    match value {\n        rusqlite::types::ValueRef::Null => (json!(null), false),\n        rusqlite::types::ValueRef::Integer(value) => (json!(value), false),\n        rusqlite::types::ValueRef::Real(value) => (json!(value), false),\n        rusqlite::types::ValueRef::Text(value) => (json!(String::from_utf8_lossy(value)), false),\n        rusqlite::types::ValueRef::Blob(value) => sqlite_blob_value_to_json(value, column_decl_type),\n    }\n}\n\nfn sqlite_blob_value_to_json(bytes: &[u8], column_decl_type: Option<&str>) -> (serde_json::Value, bool) {\n    if is_sqlite_text_affinity(column_decl_type) {\n        if let Ok(text) = std::str::from_utf8(bytes) {\n            return (json!(text), false);\n        }","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/crates/dbx-sqlite-worker/src/runtime.rs#L203-L239","documentation":"Returned by restore in the sqlite worker when restoring the database from a source (conn.restore of DatabaseName::Main) fails — the source file is not a valid SQLite backup, is locked, or the restore API errored. The source path was already validated as non-empty/NUL-free; this is the engine-level restore failure with the rusqlite error embedded.","triggerScenarios":"Thrown at crates/dbx-sqlite-worker/src/runtime.rs:221 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the source file is a valid SQLite database backup (sqlite3 source .recover / integrity_check)","Ensure the source file is readable and not locked by another process","Check disk space and permissions on the target database path","Retry after closing other connections to the target database"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}