atuinsh/atuin · error

trailing bytes in encoded kvrecord. malformed

Error message

trailing bytes in encoded kvrecord. malformed

What it means

Decoder guard in KvRecord::deserialize (V0 branch): after reading namespace, key, and optional value, bytes remain unconsumed. A valid v0 KV record ends exactly at its last field, so trailing bytes indicate a malformed record — corruption, truncation, or an encoder that wrote more fields than the decoder expects.

Source

Thrown at crates/atuin-kv/src/store/record.rs:56

            eyre!("{err:?}")
        }

        match version {
            RecordVersion::V0 => {
                let mut bytes = decode::Bytes::new(&data.0);

                let nfields = decode::read_array_len(&mut bytes).map_err(error_report)?;
                ensure!(nfields == 3, "too many entries in v0 kv record");

                let bytes = bytes.remaining_slice();

                let (namespace, bytes) =
                    decode::read_str_from_slice(bytes).map_err(error_report)?;
                let (key, bytes) = decode::read_str_from_slice(bytes).map_err(error_report)?;
                let (value, bytes) = decode::read_str_from_slice(bytes).map_err(error_report)?;

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

                Ok(Self {
                    namespace: namespace.to_owned(),
                    key: key.to_owned(),
                    value: Some(value.to_owned()),
                })
            }
            RecordVersion::V1 => {
                let mut bytes = decode::Bytes::new(&data.0);

                let nfields = decode::read_array_len(&mut bytes).map_err(error_report)?;
                ensure!(nfields == 4, "too many entries in v1 kv record");

                let bytes = bytes.remaining_slice();

                let (namespace, bytes) =
                    decode::read_str_from_slice(bytes).map_err(error_report)?;

View on GitHub (pinned to c0c717ab04)

Solutions

  1. Delete and re-write the affected KV record, or re-sync the kv store
  2. Check for disk corruption or interrupted writes
  3. Reproduce with a fresh sync before reporting upstream
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/atuin-kv/src/store/record.rs:56 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/fa70ac95ef624725. Report an issue: GitHub.