atuinsh/atuin · error
trailing bytes in encoded dotfiles env record, malformed
Error message
trailing bytes in encoded dotfiles env record, malformed
What it means
After reading the name, value, and export flag from a v0 dotfiles env record, the decoder requires the byte slice to be fully consumed. Leftover bytes mean the payload has more data than the v0 schema defines, so it is treated as malformed and rejected. This protects against truncated/corrupted or future-format records.
Source
Thrown at crates/atuin-dotfiles/src/shell.rs:65
let nfields = decode::read_array_len(bytes).map_err(error_report)?;
ensure!(
nfields == 3,
"too many entries in v0 dotfiles env create record, got {}, expected {}",
nfields,
3
);
let bytes = bytes.remaining_slice();
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)?;
let mut bytes = decode::Bytes::new(bytes);
let export = decode::read_bool(&mut bytes).map_err(error_report)?;
ensure!(
bytes.remaining_slice().is_empty(),
"trailing bytes in encoded dotfiles env record, malformed"
);
Ok(Self {
name: key.to_owned(),
value: value.to_owned(),
export,
})
}
}
#[must_use]
pub fn parse_alias(line: &str) -> Option<Alias> {
// consider the fact we might be importing a fish alias
// 'alias' output
// fish: alias foo bar
// posix: foo=barView on GitHub (pinned to c0c717ab04)
Solutions
- Upgrade all atuin clients to the latest version so record formats match
- Delete the malformed record from the record store and re-create the env var
- Verify sync integrity by re-syncing from a machine with correct data
- Check disk health / DB integrity if corruption recurs
Defensive patterns
Strategy: validation
Validate before calling
// ensure payload is fully consumed by the schema before trusting it
let mut b = rmp::decode::Bytes::new(&payload);
// ...read all 3 fields...
if !b.remaining_slice().is_empty() { return Err("trailing bytes".into()); } Try / catch
match DotfileEnvRecord::deserialize(&data) {
Ok(rec) => apply(rec),
Err(e) => log::warn!("dropping malformed env record: {e}"),
} Prevention
- Upgrade all clients together when the record format changes
- Avoid third-party tools writing to the record store
- Re-sync from a healthy host if corruption appears
- Monitor sync for records that repeatedly fail to decode
When it happens
Trigger: Deserializing a v0 dotfiles env record whose msgpack payload still has remaining bytes after reading key, value, and the boolean export flag.
Common situations: Corrupted sync payloads; records written by a newer schema synced into an older client; tampered or partially-written record store data.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- too many entries in v0 dotfiles env create record, got {}, e
- too many entries in v0 dotfiles var delete record
- too many entries in v0 shell alias create record
- too many entries in v0 shell alias delete record
- too many entries in v0 kv record
AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12).
Data as JSON: /api/errors/9cdcddce087fa151.
Report an issue: GitHub.