linera-io/linera-protocol · warning

empty

Error message

empty

What it means

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.

Source

Thrown at linera-storage/src/decode_key.rs:84

            &bytes[strip..]
        } else {
            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")
    }

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Skip empty inputs — the CLI already tolerates them, this matters only when calling decode() directly
  2. If every key reports empty, your --strip-bytes value equals or exceeds the blob length; lower it
  3. Feed real hex-encoded blobs (with optional 0x prefix), one per line or argument
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust: skip empty payloads before decoding (the CLI already does this)
if bytes.is_empty() {
    // nothing to decode; treat as skip, not error
    continue;
}

Try / catch

match decode(payload) {
    Ok(rendered) => println!("{trimmed}\t{rendered}"),
    Err(e) => println!("{trimmed}\tINVALID: {e}"), // 'empty' and 'bcs' both land here; keep going
}

Prevention

When it happens

Trigger: 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).

Common situations: Piping cqlsh table dumps that contain empty cells; over-stripping with a too-large --strip-bytes value; blank lines in stdin input.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/0a6331468b0fa91f. Report an issue: GitHub.