{"record":{"id":"2cf61363fa7b68ef","repo":"risingwavelabs/risingwave","slug":"invalid-datetime-value-unit-is-out-of-range","errorCode":null,"errorMessage":"Invalid datetime: {value} {unit} is out of range","messagePattern":"Invalid datetime: (.+?) (.+?) is out of range","errorType":"validation","errorClass":"InvalidParamsError","httpStatus":null,"severity":"error","filePath":"src/common/src/types/datetime.rs","lineNumber":257,"sourceCode":"    fn from(interval: Interval) -> Self {\n        let usecs = interval.usecs_of_day();\n        let secs = (usecs / 1_000_000) as u32;\n        let nano = (usecs % 1_000_000 * 1000) as u32;\n        Time::from_num_seconds_from_midnight_uncheck(secs, nano)\n    }\n}\n\n#[derive(Copy, Clone, Debug, Error)]\nenum ErrorKind {\n    #[error(\"Invalid date: days: {days}\")]\n    Date { days: i32 },\n    #[error(\"Invalid time: secs: {secs}, nanoseconds: {nsecs}\")]\n    Time { secs: u32, nsecs: u32 },\n    #[error(\"Invalid time: {value} {unit} is out of range for a time of day\")]\n    TimeOfDay { value: u64, unit: &'static str },\n    #[error(\"Invalid datetime: seconds: {secs}, nanoseconds: {nsecs}\")]\n    DateTime { secs: i64, nsecs: u32 },\n    #[error(\"Invalid datetime: {value} {unit} is out of range\")]\n    Timestamp { value: i64, unit: &'static str },\n    #[error(\"Can't cast string to date (expected format is YYYY-MM-DD)\")]\n    ParseDate,\n    #[error(\n        \"Can't cast string to time (expected format is HH:MM:SS[.D+{{up to 6 digits}}][Z] or HH:MM)\"\n    )]\n    ParseTime,\n    #[error(\n        \"Can't cast string to timestamp (expected format is YYYY-MM-DD HH:MM:SS[.D+{{up to 9 digits}}] or YYYY-MM-DD HH:MM or YYYY-MM-DD or ISO 8601 format)\"\n    )]\n    ParseTimestamp,\n}\n\n#[derive(Debug, Error)]\n#[error(transparent)]\npub struct InvalidParamsError(#[from] ErrorKind);\n\nimpl InvalidParamsError {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/types/datetime.rs#L239-L275","documentation":"ErrorKind::Timestamp is raised when a millisecond or microsecond count since the Unix epoch cannot be converted into a Timestamp: DateTime::from_timestamp_millis/micros returns None because the value is out of chrono's representable range. It is produced via InvalidParamsError::timestamp(value, unit) from Timestamp::with_millis / Timestamp::with_micros.","triggerScenarios":"Timestamp::with_millis(ms) or Timestamp::with_micros(us) with values beyond ~ +/-262,000 years from 1970 (out of chrono NaiveDateTime range); protobuf deserialization paths that feed a raw i64 into with_micros.","commonSituations":"Downstream systems sending sentinel values (e.g. i64::MAX) for 'unknown timestamp'; unit confusion where a value in nanoseconds is passed to with_micros; corrupted protobuf frames.","solutions":["Clamp or validate the epoch value to chrono's representable range before calling with_millis/with_micros.","Confirm the value's unit (ms vs us vs ns) matches the constructor being used.","Treat sentinel/placeholder values (i64::MIN/MAX, 0 meaning 'unset') explicitly before conversion."],"exampleFix":"// before\nlet ts = Timestamp::with_micros(raw_i64)?;\n// after\nlet ts = if raw_i64 == i64::MAX { None } else { Some(Timestamp::with_micros(raw_i64)?) };","handlingStrategy":"validation","validationCode":"fn can_be_timestamp_millis(ms: i64) -> bool {\n    DateTime::from_timestamp_millis(ms).is_some()\n}","typeGuard":"fn is_plausible_epoch_millis(ms: i64) -> bool {\n    (-62_167_219_200_000..=253_402_300_799_999).contains(&ms)\n}","tryCatchPattern":"let ts = Timestamp::with_millis(ms)\n    .map_err(|e| anyhow!(\"epoch ms {ms} out of range: {e}\"))?;","preventionTips":["Explicitly handle sentinel values like i64::MAX before conversion.","Confirm unit (ms/us/ns) matches the constructor used.","Bound-check incoming epoch values at system boundaries (ingest/ETL)."],"tags":["rust","timestamp","value-out-of-range","epoch"],"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"}