{"record":{"id":"ac9538329309064a","repo":"ajeetdsouza/zoxide","slug":"could-not-deserialize-database-corrupted-data","errorCode":null,"errorMessage":"could not deserialize database: corrupted data","messagePattern":"could not deserialize database: corrupted data","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/db/mod.rs","lineNumber":216,"sourceCode":"            // Serialize sections into buffer.\n            bincode::serialize_into(&mut buffer, &Self::VERSION)?;\n            bincode::serialize_into(&mut buffer, &dirs)?;\n\n            Ok(buffer)\n        })()\n        .context(\"could not serialize database\")\n    }\n\n    fn deserialize(bytes: &[u8]) -> Result<Vec<Dir<'_>>> {\n        // Assume a maximum size for the database. This prevents bincode from throwing\n        // strange errors when it encounters invalid data.\n        const MAX_SIZE: u64 = 32 << 20; // 32 MiB\n        let deserializer = &mut bincode::options().with_fixint_encoding().with_limit(MAX_SIZE);\n\n        // Split bytes into sections.\n        let version_size = deserializer.serialized_size(&Self::VERSION).unwrap() as _;\n        if bytes.len() < version_size {\n            bail!(\"could not deserialize database: corrupted data\");\n        }\n        let (bytes_version, bytes_dirs) = bytes.split_at(version_size);\n\n        // Deserialize sections.\n        let version = deserializer.deserialize(bytes_version)?;\n        let dirs = match version {\n            Self::VERSION => {\n                deserializer.deserialize(bytes_dirs).context(\"could not deserialize database\")?\n            }\n            version => {\n                bail!(\"unsupported version (got {version}, supports {})\", Self::VERSION)\n            }\n        };\n\n        Ok(dirs)\n    }\n}\n","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/ajeetdsouza/zoxide/blob/8a3f76da90cc12547b593ca210b8fdfb1631d07f/src/db/mod.rs#L198-L234","documentation":"Error \"could not deserialize database: corrupted data\" thrown in ajeetdsouza/zoxide.","triggerScenarios":"Thrown at src/db/mod.rs:216 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the database from a backup if available","Delete the corrupted database file and let zoxide recreate it (ranking history will be lost)"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8a3f76da90cc12547b593ca210b8fdfb1631d07f","analyzedAt":"2026-08-19T03:25:13.308Z","contentChangedAt":"2026-08-19T03:25:13.308Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}