{"record":{"id":"836d52f306f36322","repo":"tinyhumansai/openhuman","slug":"rebuilt-whatsapp-data-db-still-fails-integrity-che","errorCode":null,"errorMessage":"rebuilt whatsapp_data db still fails integrity_check at {}","messagePattern":"rebuilt whatsapp_data db still fails integrity_check at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src-tauri/src/whatsapp_data/store.rs","lineNumber":375,"sourceCode":"        //    check itself can't run — we MUST surface `Err`, otherwise the\n        //    latch resets, re-arming Sentry to page on the next scan tick and\n        //    breaking the report-once-per-episode guarantee this recovery\n        //    exists to protect.\n        match self.integrity_check_ok() {\n            Ok(true) => {\n                log::warn!(\n                    \"[whatsapp_data] corruption recovery complete: quarantined {quarantined} file(s), \\\n                     rebuilt empty schema, integrity_check=ok at {}\",\n                    self.db_path.display()\n                );\n                Ok(true)\n            }\n            Ok(false) => {\n                log::error!(\n                    \"[whatsapp_data] rebuilt DB still fails integrity_check at {}\",\n                    self.db_path.display()\n                );\n                Err(anyhow::anyhow!(\n                    \"rebuilt whatsapp_data db still fails integrity_check at {}\",\n                    self.db_path.display()\n                ))\n            }\n            Err(e) => Err(e.context(\"integrity_check after rebuild could not run\")),\n        }\n    }\n\n    /// Run `PRAGMA quick_check(1)` on a fresh, short-lived connection. Returns\n    /// `Ok(true)` when the structural scan reports `\"ok\"`, `Ok(false)` on any\n    /// reported corruption, and `Err` when the check itself can't run (file\n    /// unopenable / header unreadable — itself a corruption signal the caller\n    /// treats as malformed).\n    fn quick_check_ok(&self) -> Result<bool> {\n        let conn = Connection::open(&self.db_path)\n            .with_context(|| format!(\"open for quick_check: {}\", self.db_path.display()))?;\n        let _ = conn.busy_timeout(BUSY_TIMEOUT);\n        let result: String = conn","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/a221052e0df5b1f7598fceba7329fd1af95d6699/app/src-tauri/src/whatsapp_data/store.rs#L357-L393","documentation":"whatsapp_data's corruption recovery already ran: bad files were quarantined and an empty schema rebuilt — yet the follow-up integrity_check on the rebuilt database still reports corruption (Ok(false)). This means the storage location or the rebuild path itself is unhealthy, not merely one damaged input file; the error includes the db path.","triggerScenarios":"Disk-level corruption at the whatsapp_data db path so even the fresh rebuild comes back corrupt; an external process (cloud-sync client, antivirus) rewriting the new file as it is created; the db living on unreliable removable/network storage.","commonSituations":"Workspace under Dropbox/OneDrive/iCloud sync mutating SQLite files; failing SSD sectors; recovery loops where each quarantine+rebuild cycle corrupts again.","solutions":["Stop the app and delete the whatsapp_data db directory entirely — it is a cache re-derived from WhatsApp data — then relaunch so it is created fresh","Exclude the db directory from sync clients and AV scans, or move the workspace off synced/removable storage","If corruption recurs across unrelated files, check disk health (SMART) — this is then a hardware symptom, not an app bug"],"exampleFix":"# before — log loops: rebuilt whatsapp_data db still fails integrity_check at <path>\n# after — nuke the cache db and let the app rebuild from scratch\n rm -rf '<path-from-the-error-message>'/*.db*   # path is printed in the error\n# then relaunch the app","handlingStrategy":"fallback","validationCode":"// probe the store before scheduling ingestion\nif !store.quick_check().unwrap_or(false) {\n    // one recovery attempt is the design; a second failure means the location is bad\n    log::error!(\"[whatsapp_data] corruption detected — recovery will run once\");\n}","typeGuard":null,"tryCatchPattern":"match store.recover_if_corrupt() {\n    Ok(true) => log::info!(\"[whatsapp_data] recovered\"),\n    Ok(false) => {}\n    Err(e) if e.to_string().contains(\"still fails integrity_check\") => {\n        log::error!(\"[whatsapp_data] quarantine loop — deleting db dir for full rebuild\");\n        store.delete_db_dir()?;  // cache is re-derivable from WhatsApp data\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["exclude SQLite files from sync clients and AV scanners","never retry the same recovery after a failed post-rebuild check — delete and rebuild","monitor recovery events: once is normal, a pattern is storage hardware"],"tags":["sqlite","corruption","whatsapp","recovery","data-integrity"],"backgroundTag":null,"analyzedSha":"a221052e0df5b1f7598fceba7329fd1af95d6699","analyzedAt":"2026-08-16T12:47:06.542Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}