{"record":{"id":"d8d3eee0c9b94bc2","repo":"risingwavelabs/risingwave","slug":"invalid-date-value-encoding-days-0","errorCode":null,"errorMessage":"Invalid Date value encoding: days: {0}","messagePattern":"Invalid Date value encoding: days: (.+?)","errorType":"error_code","errorClass":"ValueEncodingError","httpStatus":null,"severity":"error","filePath":"src/common/src/util/value_encoding/error.rs","lineNumber":23,"sourceCode":"// 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]\n        #[backtrace]\n        crate::array::ArrayError,\n    ),\n    #[error(\"Invalid list encoding: {0}\")]","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/util/value_encoding/error.rs#L5-L41","documentation":"`ValueEncodingError::InvalidDateEncoding` is raised when decoding a value-encoded DATE: the day count is stored as an i32 (days since 1970-01-01) and reconstruction via `NaiveDate::from_num_days_from_ce`-style conversion fails when the value is out of the representable date range. The message reports the offending day count.","triggerScenarios":"Decoding a DATE from bytes whose i32 day value is out of range (e.g. i32::MIN/MAX, negative extremes, or a value produced by a different format), reading at a wrong offset so arbitrary bytes are interpreted as the day count.","commonSituations":"Hand-crafted encoders writing raw integers outside the supported calendar range, corrupt/truncated storage or Kafka payloads, endian/format mismatches between writer and reader when users serialize externally.","solutions":["Ensure the encoded i32 day count falls within RisingWave's supported DATE range before decoding","Fix read offsets so the correct 4 bytes are interpreted as the day count","Check the reported `days` value against your writer's output to locate corruption","Regenerate the data with RisingWave's own value-encoding `memcomparable`/value encode APIs instead of hand-rolling"],"exampleFix":"// before\nlet days = i32::MAX; // out of representable date range\nlet d = NaiveDate::try_from_value_encoding(&days.to_be_bytes())?;\n// after\nlet days = 19_000i32; // valid day count (≈2022)\nlet d = NaiveDate::try_from_value_encoding(&days.to_be_bytes())?;","handlingStrategy":"validation","validationCode":"// range-check day count before encoding/decoding a DATE\nfn is_valid_date_days(days: i32) -> bool {\n    chrono::NaiveDate::from_num_days_from_ce_opt(days).is_some()\n}\n","typeGuard":null,"tryCatchPattern":"match NaiveDate::try_from_value_encoding(bytes) {\n    Ok(d) => d,\n    Err(ValueEncodingError::InvalidDateEncoding(days)) => {\n        return Err(anyhow!(\"DATE days={days} out of supported calendar range\"));\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Clamp/validate day counts to the supported calendar range before encoding","Do not hand-roll date serialization; use value-encoding APIs","Check offsets/endianness when manually slicing encoded buffers"],"tags":["value-encoding","date","deserialization","risingwave"],"backgroundTag":"value-out-of-range","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"}