linera-io/linera-protocol · warning
bcs: {e}
Error message
bcs: {e} What it means
decode_key's decode() runs bcs::from_bytes over the payload to reconstruct a RootKey. This error wraps the underlying BCS failure: the bytes decoded from hex fine, but they are not a valid BCS serialization of any RootKey variant. The CLI prints 'INVALID: bcs: <reason>' and keeps going.
Source
Thrown at linera-storage/src/decode_key.rs:86
writeln!(
out,
"{trimmed}\tINVALID: shorter than --strip-bytes={strip}"
)?;
continue;
};
match decode(payload) {
Ok(rendered) => writeln!(out, "{trimmed}\t{rendered}")?,
Err(error) => writeln!(out, "{trimmed}\tINVALID: {error}")?,
}
}
Ok(())
}
fn decode(bytes: &[u8]) -> Result<String> {
if bytes.is_empty() {
return Err(anyhow!("empty"));
}
let key: RootKey = bcs::from_bytes(bytes).map_err(|e| anyhow!("bcs: {e}"))?;
Ok(format!("{key:?}"))
}
#[cfg(test)]
mod tests {
use linera_base::{
crypto::CryptoHash,
identifiers::{BlobId, BlobType, ChainId},
};
use linera_storage::RootKey;
use super::decode;
fn roundtrip(key: RootKey) -> String {
decode(&key.bytes()).expect("decode")
}
#[test]View on GitHub (pinned to 6c226ddcb3)
Solutions
- For ScyllaDB dumps, pass --scylla (shorthand for --strip-bytes 1) to drop the prepended tag byte
- Try nearby strip offsets: --strip-bytes 0, 1, 2 — the message INVALID output tells you which decode failed, so iterate
- Confirm the blob is actually a RootKey partition key and not an application-level key or a value blob
Example fix
# before cat dump.txt | linera-storage-decode-key # after cat dump.txt | linera-storage-decode-key --scylla
Defensive patterns
Strategy: fallback
Try / catch
match decode(payload) {
Ok(rendered) => writeln!(out, "{}\t{}", trimmed, rendered)?,
Err(e) => writeln!(out, "{}\tINVALID: {}", trimmed, e)?, // record and continue with the next key
} Prevention
- Always pass --scylla when decoding ScyllaDB dump output (one tag byte is prepended per root key)
- Try strip offsets 0/1/2 when the source backend is unknown; keep the one that yields the fewest INVALID lines
- Confirm the blob came from a compatible linera version before decoding cross-version dumps
When it happens
Trigger: Hex that is well-formed but not a RootKey: a wrong --strip-bytes offset (payload still carries the tag byte or lost a real byte), a value key or another table's partition key, or a RootKey format from an incompatible linera version.
Common situations: Forgetting --scylla when reading ScyllaDB dumps (each root key has one extra leading 0x00 byte); passing arbitrary DB keys found in rocksdb logs; schema/enum changes between versions altering the BCS layout.
Related errors
- empty
- Invalid chain description data for chain {chain_id}
- Failed to parse {spawn_mode_name} as a spawn_mode
- Failed to find address for {s}. {parse_error}
- Failed to find port for {s}. {parse_error}
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/f9c695f7d4d3e8ef.
Report an issue: GitHub.