{"record":{"id":"0a6331468b0fa91f","repo":"linera-io/linera-protocol","slug":"empty","errorCode":null,"errorMessage":"empty","messagePattern":"empty","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"linera-storage/src/decode_key.rs","lineNumber":84,"sourceCode":"            &bytes[strip..]\n        } else {\n            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    }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-storage/src/decode_key.rs#L66-L102","documentation":"The linera-storage decode_key utility decodes hex blobs into RootKey partition keys. decode() rejects a zero-length payload with 'empty' before attempting BCS deserialization; the CLI prints '<input>\\tINVALID: empty' and continues rather than crashing.","triggerScenarios":"Feeding '0x' (prefix with no digits), an empty token after splitting on whitespace/'|'/',', or a blob whose entire content was consumed by --strip-bytes/--scylla stripping (e.g. a single 0x00 byte with --scylla).","commonSituations":"Piping cqlsh table dumps that contain empty cells; over-stripping with a too-large --strip-bytes value; blank lines in stdin input.","solutions":["Skip empty inputs — the CLI already tolerates them, this matters only when calling decode() directly","If every key reports empty, your --strip-bytes value equals or exceeds the blob length; lower it","Feed real hex-encoded blobs (with optional 0x prefix), one per line or argument"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Rust: skip empty payloads before decoding (the CLI already does this)\nif bytes.is_empty() {\n    // nothing to decode; treat as skip, not error\n    continue;\n}","typeGuard":null,"tryCatchPattern":"match decode(payload) {\n    Ok(rendered) => println!(\"{trimmed}\\t{rendered}\"),\n    Err(e) => println!(\"{trimmed}\\tINVALID: {e}\"), // 'empty' and 'bcs' both land here; keep going\n}","preventionTips":["Filter blank lines and bare '0x' tokens when preparing input files","Keep --strip-bytes smaller than the shortest blob you expect","Treat INVALID lines as normal output of the audit tool, not crashes"],"tags":["linera","storage","debugging","bcs","cli"],"backgroundTag":"empty-payload-decode","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}