{"record":{"id":"a97ffb82d411a97d","repo":"risingwavelabs/risingwave","slug":"invalid-bool-value-encoding-0","errorCode":null,"errorMessage":"Invalid bool value encoding: {0}","messagePattern":"Invalid bool value encoding: (.+?)","errorType":"error_code","errorClass":"ValueEncodingError","httpStatus":null,"severity":"error","filePath":"src/common/src/util/value_encoding/error.rs","lineNumber":19,"sourceCode":"// Copyright 2022 RisingWave Labs\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n//     http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nuse thiserror::Error;\n\n#[derive(Error, Debug)]\npub enum ValueEncodingError {\n    #[error(\"Invalid bool value encoding: {0}\")]\n    InvalidBoolEncoding(u8),\n    #[error(\"Invalid UTF8 value encoding: {0}\")]\n    InvalidUtf8(#[from] std::string::FromUtf8Error),\n    #[error(\"Invalid Date value encoding: days: {0}\")]\n    InvalidDateEncoding(i32),\n    #[error(\"invalid Timestamp value encoding: secs: {0} nsecs: {1}\")]\n    InvalidTimestampEncoding(i64, u32),\n    #[error(\"invalid Time value encoding: secs: {0} nano: {1}\")]\n    InvalidTimeEncoding(u32, u32),\n    #[error(\"Invalid null tag value encoding: {0}\")]\n    InvalidTagEncoding(u8),\n    #[error(\"Invalid jsonb encoding\")]\n    InvalidJsonbEncoding,\n    #[error(\"Invalid variant encoding\")]\n    InvalidVariantEncoding,\n    #[error(\"Invalid struct encoding: {0}\")]\n    InvalidStructEncoding(\n        #[source]","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/util/value_encoding/error.rs#L1-L37","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the bytes you decode were produced by RisingWave's value encoding for a bool (0x00/0x01), not another format","Check read offsets/slicing — a misaligned offset turns another field's byte into the bool position","Re-generate or re-sync the corrupted data source; inspect the offending byte value shown in the message","Ensure writer and reader use compatible RisingWave versions/encodings"],"exampleFix":"// before\nlet bytes = vec![2u8]; // invalid bool byte\nlet v = bool::try_from_value_encoding(&bytes)?;\n// after\nlet bytes = vec![1u8]; // 0 = false, 1 = true\nlet v = bool::try_from_value_encoding(&bytes)?;","handlingStrategy":"try-catch","validationCode":"// check the bool byte before decoding\nfn is_valid_bool_encoding(bytes: &[u8]) -> bool {\n    matches!(bytes.first(), Some(0) | Some(1))\n}\n","typeGuard":"fn valid_bool_byte(b: u8) -> Option<bool> { match b { 0 => Some(false), 1 => Some(true), _ => None } }","tryCatchPattern":"match bool::try_from_value_encoding(bytes) {\n    Ok(v) => v,\n    Err(ValueEncodingError::InvalidBoolEncoding(b)) => {\n        // log offending byte b, treat as corrupt input\n        return Err(anyhow!(\"corrupt bool encoding, byte={b}\"));\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Encode bools only with RisingWave's value-encoding APIs (0/1 bytes)","Verify buffer offsets before decoding each field","Keep writer and reader on compatible versions","Checksum data pipelines to catch corruption early"],"tags":["value-encoding","deserialization","bool","risingwave"],"backgroundTag":"invalid-argument-value","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}