atuinsh/atuin · error

trailing bytes in encoded script record. malformed

Error message

trailing bytes in encoded script record. malformed

What it means

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.

Source

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

        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;
        }

        let (script, bytes) = decode::read_str_from_slice(bytes).unwrap();

        if !bytes.is_empty() {
            bail!("trailing bytes in encoded script record. malformed");
        }

        Ok(Self {
            id: Uuid::parse_str(id).unwrap(),
            name: name.to_owned(),
            description: description.to_owned(),
            shebang: shebang.to_owned(),
            tags,
            script: script.to_owned(),
        })
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]

View on GitHub (pinned to c0c717ab04)

Solutions

  1. Delete and re-create the affected script record, then re-sync the scripts store
  2. Check for disk corruption or interrupted sync writes
  3. Verify all clients use a matching Atuin version
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/atuin-scripts/src/store/script.rs:93 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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