{"record":{"id":"ed51117416455b0d","repo":"atuinsh/atuin","slug":"trailing-bytes-in-encoded-script-record-malformed","errorCode":null,"errorMessage":"trailing bytes in encoded script record. malformed","messagePattern":"trailing bytes in encoded script record\\. malformed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-scripts/src/store/script.rs","lineNumber":93,"sourceCode":"        let (description, bytes) = decode::read_str_from_slice(bytes).unwrap();\n        let (shebang, bytes) = decode::read_str_from_slice(bytes).unwrap();\n\n        let mut bytes = Bytes::new(bytes);\n        let tags_len = decode::read_array_len(&mut bytes).unwrap();\n\n        let mut bytes = bytes.remaining_slice();\n\n        let mut tags = Vec::new();\n        for _ in 0..tags_len {\n            let (tag, remaining) = decode::read_str_from_slice(bytes).unwrap();\n            tags.push(tag.to_owned());\n            bytes = remaining;\n        }\n\n        let (script, bytes) = decode::read_str_from_slice(bytes).unwrap();\n\n        if !bytes.is_empty() {\n            bail!(\"trailing bytes in encoded script record. malformed\");\n        }\n\n        Ok(Self {\n            id: Uuid::parse_str(id).unwrap(),\n            name: name.to_owned(),\n            description: description.to_owned(),\n            shebang: shebang.to_owned(),\n            tags,\n            script: script.to_owned(),\n        })\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin-scripts/src/store/script.rs#L75-L111","documentation":"Decoder guard in the scripts store's record decoding: after parsing name, description, shebang, tags, and script body of a v0 script record, unconsumed bytes remain. A well-formed record ends exactly at its last field, so trailing bytes signal a malformed record — corruption, truncation, or an encoder/decoder format mismatch.","triggerScenarios":"Thrown at crates/atuin-scripts/src/store/script.rs:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete and re-create the affected script record, then re-sync the scripts store","Check for disk corruption or interrupted sync writes","Verify all clients use a matching Atuin version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}