{"record":{"id":"f9c695f7d4d3e8ef","repo":"linera-io/linera-protocol","slug":"bcs-e","errorCode":null,"errorMessage":"bcs: {e}","messagePattern":"bcs: \\{e\\}","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"linera-storage/src/decode_key.rs","lineNumber":86,"sourceCode":"            writeln!(\n                out,\n                \"{trimmed}\\tINVALID: shorter than --strip-bytes={strip}\"\n            )?;\n            continue;\n        };\n        match decode(payload) {\n            Ok(rendered) => writeln!(out, \"{trimmed}\\t{rendered}\")?,\n            Err(error) => writeln!(out, \"{trimmed}\\tINVALID: {error}\")?,\n        }\n    }\n    Ok(())\n}\n\nfn decode(bytes: &[u8]) -> Result<String> {\n    if bytes.is_empty() {\n        return Err(anyhow!(\"empty\"));\n    }\n    let key: RootKey = bcs::from_bytes(bytes).map_err(|e| anyhow!(\"bcs: {e}\"))?;\n    Ok(format!(\"{key:?}\"))\n}\n\n#[cfg(test)]\nmod tests {\n    use linera_base::{\n        crypto::CryptoHash,\n        identifiers::{BlobId, BlobType, ChainId},\n    };\n    use linera_storage::RootKey;\n\n    use super::decode;\n\n    fn roundtrip(key: RootKey) -> String {\n        decode(&key.bytes()).expect(\"decode\")\n    }\n\n    #[test]","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-storage/src/decode_key.rs#L68-L104","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ncat dump.txt | linera-storage-decode-key\n# after\ncat dump.txt | linera-storage-decode-key --scylla","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match decode(payload) {\n    Ok(rendered) => writeln!(out, \"{}\\t{}\", trimmed, rendered)?,\n    Err(e) => writeln!(out, \"{}\\tINVALID: {}\", trimmed, e)?, // record and continue with the next key\n}","preventionTips":["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"],"tags":["linera","storage","bcs","deserialization","debugging"],"backgroundTag":"deserialization-failed","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}