{"record":{"id":"a3b4ec7fd93a416b","repo":"atuinsh/atuin","slug":"expected-to-decode-version-record-found-v-real","errorCode":null,"errorMessage":"expected to decode {version} record, found v{real_version}","messagePattern":"expected to decode (.+?) record, found v(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-client/src/history.rs","lineNumber":291,"sourceCode":"            self.deleted_at.map(|d| d.unix_timestamp_nanos() as u64),\n            encode::write_u64,\n        )?;\n        encode::write_str(&mut output, self.author.as_str())?;\n        encode::write_optional(&mut output, self.intent.as_deref(), encode::write_str)?;\n        encode::write_optional(&mut output, self.shell.as_deref(), encode::write_str)?;\n        Ok(DecryptedData(output.into_vec()))\n    }\n\n    pub fn deserialize(bytes: &[u8], version: &str) -> Result<History> {\n        let Some(version) = Version::from_name(version) else {\n            bail!(\"unknown version {version:?}\");\n        };\n\n        let mut bytes = Bytes::new(bytes);\n\n        let real_version = decode::read_u16(&mut bytes).map_err(DecodeError::from)?;\n        if real_version != version.as_int() {\n            bail!(\"expected to decode {version} record, found v{real_version}\");\n        }\n\n        let nfields = decode::read_array_len(&mut bytes).map_err(DecodeError::from)?;\n        let min_fields = version.min_fields();\n        if nfields < min_fields || version.max_fields().is_some_and(|max| nfields > max) {\n            bail!(\"unexpected number of fields ({nfields}) for history version {version}\");\n        }\n\n        let id = decode::read_string(&mut bytes)?;\n        let timestamp = decode::read_u64(&mut bytes).map_err(DecodeError::from)?;\n        let duration = decode::read_int(&mut bytes).map_err(DecodeError::from)?;\n        let exit = decode::read_int(&mut bytes).map_err(DecodeError::from)?;\n\n        let command = decode::read_string(&mut bytes)?;\n        let cwd = decode::read_string(&mut bytes)?;\n        let session = decode::read_string(&mut bytes)?;\n        let hostname = decode::read_string(&mut bytes)?;\n        let deleted_at = decode::read_optional(&mut bytes, decode::read_u64)?;","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/atuinsh/atuin/blob/15fe1318f1df51de604262eb50734c9883d48e7b/crates/atuin-client/src/history.rs#L273-L309","documentation":"Error \"expected to decode {version} record, found v{real_version}\" thrown in atuinsh/atuin.","triggerScenarios":"Fires when a record advertises one history version but the decoded data carries a different version.","commonSituations":"See trigger scenarios.","solutions":["The record was encoded with a different version than expected; upgrade atuin or re-sync the store."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"15fe1318f1df51de604262eb50734c9883d48e7b","analyzedAt":"2026-08-19T08:56:57.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}