risingwavelabs/risingwave · error · ValueEncodingError

Invalid bool value encoding: {0}

Error message

Invalid bool value encoding: {0}

What it means

`ValueEncodingError::InvalidBoolEncoding` is thrown while decoding a value-encoded bool column in RisingWave. Bools are encoded as a single u8 byte and only 0 (false) and 1 (true) are valid; any other byte means the buffer is not a well-formed value-encoded bool.

Source

Thrown at src/common/src/util/value_encoding/error.rs:19

// Copyright 2022 RisingWave Labs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use thiserror::Error;

#[derive(Error, Debug)]
pub enum ValueEncodingError {
    #[error("Invalid bool value encoding: {0}")]
    InvalidBoolEncoding(u8),
    #[error("Invalid UTF8 value encoding: {0}")]
    InvalidUtf8(#[from] std::string::FromUtf8Error),
    #[error("Invalid Date value encoding: days: {0}")]
    InvalidDateEncoding(i32),
    #[error("invalid Timestamp value encoding: secs: {0} nsecs: {1}")]
    InvalidTimestampEncoding(i64, u32),
    #[error("invalid Time value encoding: secs: {0} nano: {1}")]
    InvalidTimeEncoding(u32, u32),
    #[error("Invalid null tag value encoding: {0}")]
    InvalidTagEncoding(u8),
    #[error("Invalid jsonb encoding")]
    InvalidJsonbEncoding,
    #[error("Invalid variant encoding")]
    InvalidVariantEncoding,
    #[error("Invalid struct encoding: {0}")]
    InvalidStructEncoding(
        #[source]

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Verify the bytes you decode were produced by RisingWave's value encoding for a bool (0x00/0x01), not another format
  2. Check read offsets/slicing — a misaligned offset turns another field's byte into the bool position
  3. Re-generate or re-sync the corrupted data source; inspect the offending byte value shown in the message
  4. Ensure writer and reader use compatible RisingWave versions/encodings

Example fix

// before
let bytes = vec![2u8]; // invalid bool byte
let v = bool::try_from_value_encoding(&bytes)?;
// after
let bytes = vec![1u8]; // 0 = false, 1 = true
let v = bool::try_from_value_encoding(&bytes)?;
Defensive patterns

Strategy: try-catch

Validate before calling

// check the bool byte before decoding
fn is_valid_bool_encoding(bytes: &[u8]) -> bool {
    matches!(bytes.first(), Some(0) | Some(1))
}

Type guard

fn valid_bool_byte(b: u8) -> Option<bool> { match b { 0 => Some(false), 1 => Some(true), _ => None } }

Try / catch

match bool::try_from_value_encoding(bytes) {
    Ok(v) => v,
    Err(ValueEncodingError::InvalidBoolEncoding(b)) => {
        // log offending byte b, treat as corrupt input
        return Err(anyhow!("corrupt bool encoding, byte={b}"));
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling the value-encoding `try_from`/deserialize for bool (`Bool` type) on bytes whose first byte is not 0 or 1 — e.g. decoding a truncated, shifted, or non-value-encoded buffer, or reading at a wrong offset.

Common situations: Corrupted or truncated serialized data (Kafka/UDF payloads, internal storage), version skew between writer and reader encodings, user code that hand-builds value-encoded bytes and writes 2/0xFF for a bool, off-by-one offsets when manually slicing encoded rows.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/a97ffb82d411a97d. Report an issue: GitHub.