{"record":{"id":"483b09c3094fea8e","repo":"atuinsh/atuin","slug":"too-many-entries-in-v0-script-record","errorCode":null,"errorMessage":"too many entries in v0 script record","messagePattern":"too many entries in v0 script record","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-scripts/src/store/script.rs","lineNumber":69,"sourceCode":"        encode::write_str(&mut output, &self.name)?;\n        encode::write_str(&mut output, &self.description)?;\n        encode::write_str(&mut output, &self.shebang)?;\n        encode::write_array_len(&mut output, u32::conv(self.tags.len()))?;\n\n        for tag in &tags {\n            encode::write_str(&mut output, tag)?;\n        }\n\n        encode::write_str(&mut output, &self.script)?;\n\n        Ok(DecryptedData(output))\n    }\n\n    pub fn deserialize(bytes: &[u8]) -> Result<Self> {\n        let mut bytes = decode::Bytes::new(bytes);\n        let nfields = decode::read_array_len(&mut bytes).unwrap();\n\n        ensure!(nfields == 6, \"too many entries in v0 script record\");\n\n        let bytes = bytes.remaining_slice();\n\n        let (id, bytes) = decode::read_str_from_slice(bytes).unwrap();\n        let (name, bytes) = decode::read_str_from_slice(bytes).unwrap();\n        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;","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin-scripts/src/store/script.rs#L51-L87","documentation":"A v0 script record must be a MsgPack array of exactly 6 entries (id, name, description, and the remaining script fields). The script record deserializer checks the array length before reading and rejects other counts. Note this deserializer uses unwrap() on subsequent reads, so this ensure! is the structured guard against shape mismatches.","triggerScenarios":"Deserializing a v0 script record whose array length != 6 — e.g. records written by a different script schema version, encoders adding/removing fields, or corrupted payloads.","commonSituations":"Script records synced across Atuin versions with differing script schemas, manual record construction, or data corruption in the record store.","solutions":["Re-create the script with the current CLI so it is encoded with the expected 6-field schema.","Fix the writer to emit exactly six fields in the documented order for v0 script records.","Sync-align Atuin versions across machines."],"exampleFix":"// before: encode::to_bytes(&(id, name, description))\n// after:  encode::to_bytes(&(id, name, description, script, tags, created))","handlingStrategy":"validation","validationCode":"let value: rmpv::Value = rmpv::decode::read_value(&mut cursor)?;\n// v0 script record requires exactly 6 fields\nassert_eq!(value.as_array().map(|a| a.len()), Some(6));","typeGuard":"fn is_well_formed_v0_script(payload: &[u8]) -> bool {\n    rmpv::decode::read_value(&mut std::io::Cursor::new(payload))\n        .ok()\n        .and_then(|v| v.as_array().map(|a| a.len() == 6))\n        .unwrap_or(false)\n}","tryCatchPattern":"match Script::deserialize(&bytes) {\n    Ok(script) => install(script),\n    Err(e) if e.to_string().contains(\"too many entries\") => {\n        log::warn(\"malformed script record dropped: {e}\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Serialize scripts only via Script::serialize","Keep all six fields present and in order when writing v0 script records","Align Atuin versions across machines that sync scripts"],"tags":["serialization","msgpack","scripts"],"backgroundTag":"schema-validation-failed","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}