atuinsh/atuin · error

too many entries in v0 script record

Error message

too many entries in v0 script record

What it means

A v0 script record is a msgpack array with exactly 6 fields (id, name, description, and the remaining script metadata fields). The scripts store deserializer requires the decoded array length to be 6; anything else is rejected as malformed. This enforces the v0 scripts on-wire schema in the record store.

Source

Thrown at crates/atuin-scripts/src/store/script.rs:69

        encode::write_str(&mut output, &self.name)?;
        encode::write_str(&mut output, &self.description)?;
        encode::write_str(&mut output, &self.shebang)?;
        encode::write_array_len(&mut output, u32::conv(self.tags.len()))?;

        for tag in &tags {
            encode::write_str(&mut output, tag)?;
        }

        encode::write_str(&mut output, &self.script)?;

        Ok(DecryptedData(output))
    }

    pub fn deserialize(bytes: &[u8]) -> Result<Self> {
        let mut bytes = decode::Bytes::new(bytes);
        let nfields = decode::read_array_len(&mut bytes).unwrap();

        ensure!(nfields == 6, "too many entries in v0 script record");

        let bytes = bytes.remaining_slice();

        let (id, bytes) = decode::read_str_from_slice(bytes).unwrap();
        let (name, bytes) = decode::read_str_from_slice(bytes).unwrap();
        let (description, bytes) = decode::read_str_from_slice(bytes).unwrap();
        let (shebang, bytes) = decode::read_str_from_slice(bytes).unwrap();

        let mut bytes = Bytes::new(bytes);
        let tags_len = decode::read_array_len(&mut bytes).unwrap();

        let mut bytes = bytes.remaining_slice();

        let mut tags = Vec::new();
        for _ in 0..tags_len {
            let (tag, remaining) = decode::read_str_from_slice(bytes).unwrap();
            tags.push(tag.to_owned());
            bytes = remaining;

View on GitHub (pinned to c0c717ab04)

Solutions

  1. Upgrade atuin on all machines syncing scripts to the same version
  2. Delete the malformed script record and re-add the script via `atuin scripts new`
  3. Re-sync scripts from a known-good machine
  4. Inspect the record store DB row if the corruption is isolated
Defensive patterns

Strategy: validation

Validate before calling

let n = rmp::decode::read_array_len(&mut bytes)?;
if n != 6 { return Err("malformed v0 script record".into()); }

Try / catch

match Script::deserialize(&data) {
    Ok(script) => install(script),
    Err(e) => log::warn!("skipping malformed script record: {e}"),
}

Prevention

When it happens

Trigger: Deserializing a v0 script record whose msgpack payload decodes to an array length other than 6.

Common situations: Syncing script records from a client with a different scripts schema version; corrupted record payloads; records created by tooling writing directly to the store.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12). Data as JSON: /api/errors/483b09c3094fea8e. Report an issue: GitHub.