{"record":{"id":"0c126d98f9819d61","repo":"atuinsh/atuin","slug":"too-many-entries-in-v0-shell-alias-create-record","errorCode":null,"errorMessage":"too many entries in v0 shell alias create record","messagePattern":"too many entries in v0 shell alias create record","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin-dotfiles/src/store.rs","lineNumber":70,"sourceCode":"\n    pub fn deserialize(data: &DecryptedData, version: &RecordVersion) -> Result<Self> {\n        use rmp::decode;\n\n        fn error_report<E: std::fmt::Debug>(err: E) -> eyre::Report {\n            eyre!(\"{err:?}\")\n        }\n\n        match version {\n            RecordVersion::V0 => {\n                let mut bytes = decode::Bytes::new(&data.0);\n\n                let record_type = decode::read_u8(&mut bytes).map_err(error_report)?;\n\n                match record_type {\n                    // create\n                    0 => {\n                        let nfields = decode::read_array_len(&mut bytes).map_err(error_report)?;\n                        ensure!(nfields == 2, \"too many entries in v0 shell alias create record\");\n\n                        let bytes = bytes.remaining_slice();\n\n                        let (key, bytes) =\n                            decode::read_str_from_slice(bytes).map_err(error_report)?;\n                        let (value, bytes) =\n                            decode::read_str_from_slice(bytes).map_err(error_report)?;\n\n                        if !bytes.is_empty() {\n                            bail!(\"trailing bytes in encoded shell alias record. malformed\");\n                        }\n\n                        Ok(Self::Create(Alias {\n                            name: key.to_owned(),\n                            value: value.to_owned(),\n                        }))\n                    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/atuinsh/atuin/blob/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin-dotfiles/src/store.rs#L52-L88","documentation":"The v0 shell alias create record must be a MsgPack array of exactly 2 entries (key and value). The deserializer reads the array length and rejects any other count, since the alias type discriminator already selected the 'create' variant. Extra entries indicate a malformed or incompatible payload.","triggerScenarios":"Deserializing a v0 shell alias record whose discriminator byte is 0 (create) but whose array length is not 2 — e.g. an encoder that added fields to the create payload or supplied a 1-element array.","commonSituations":"Syncing records between Atuin versions with differing alias schemas, manually crafted records, or corrupted payloads in the record store.","solutions":["Re-create the alias so it is encoded with the current schema: `atuin dotfiles alias set <name> <value>`.","Fix the writing side to emit exactly two entries (key, value) for the create variant.","Align Atuin versions across sync peers to avoid schema skew."],"exampleFix":"// before: encode::to_bytes(&(key, value, extra))\n// after:  encode::to_bytes(&(key, value))","handlingStrategy":"validation","validationCode":"let value: rmpv::Value = rmpv::decode::read_value(&mut cursor)?;\n// create variant: discriminator 0 requires exactly 2 fields\nassert_eq!(value.as_array().map(|a| a.len()), Some(2));","typeGuard":"fn is_well_formed_alias_create(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() == 2))\n        .unwrap_or(false)\n}","tryCatchPattern":"match ShellAlias::deserialize(&bytes) {\n    Ok(alias) => apply(alias),\n    Err(e) if e.to_string().contains(\"too many entries\") => {\n        log::warn(\"skipping malformed alias record: {e}\");\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Encode alias records only via ShellAlias::serialize","Check nfields expectations before writing custom record encoders","Test encode -> deserialize round-trips in CI"],"tags":["serialization","msgpack","aliases"],"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"}