{"record":{"id":"07d370fb7f600400","repo":"risingwavelabs/risingwave","slug":"invalid-timestamp-value-encoding-secs-0-nsecs","errorCode":null,"errorMessage":"invalid Timestamp value encoding: secs: {0} nsecs: {1}","messagePattern":"invalid Timestamp value encoding: secs: (.+?) nsecs: (.+?)","errorType":"error_code","errorClass":"ValueEncodingError","httpStatus":null,"severity":"error","filePath":"src/common/src/util/value_encoding/error.rs","lineNumber":25,"sourceCode":"//     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}\")]\n    InvalidListEncoding(\n        #[source]","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/util/value_encoding/error.rs#L7-L43","documentation":"`ValueEncodingError::InvalidTimestampEncoding` is raised when decoding a value-encoded TIMESTAMP/Timestamptz: the pair (secs: i64, nsecs: u32) read from the buffer cannot be converted to a valid `NaiveDateTime` (e.g. seconds or nanoseconds outside the representable range). The message reports both components.","triggerScenarios":"Decoding a timestamp whose stored secs exceed chrono's valid range for NaiveDateTime, or whose nsecs exceed 999_999_999; wrong-offset reads that reinterpret unrelated bytes as (secs, nsecs); external writers using a different epoch or unit (e.g. millis written as secs).","commonSituations":"Hand-rolled serializers writing epoch-millis into the secs field, corrupt/truncated payloads, endian mismatch, offset errors when manually slicing value-encoded rows.","solutions":["Verify the decoded (secs, nsecs) values: nsecs must be < 1_000_000_000 and secs within NaiveDateTime's range","If your writer emits epoch millis/micros, convert to (secs, nanos) before value-encoding","Check byte offsets and endianness so the correct 12 bytes are read as the timestamp","Re-encode the data with RisingWave's value-encoding APIs"],"exampleFix":"// before\nlet (secs, nsecs) = (1_700_000_000_000i64, 0u32); // millis mistakenly in secs\n// after\nlet (secs, nsecs) = (1_700_000_000i64, 0u32); // secs + nanos pair","handlingStrategy":"validation","validationCode":"// validate the (secs, nsecs) pair before encoding a timestamp\nfn is_valid_timestamp(secs: i64, nsecs: u32) -> bool {\n    nsecs < 1_000_000_000\n        && chrono::NaiveDateTime::from_timestamp_opt(secs, nsecs).is_some()\n}\n","typeGuard":null,"tryCatchPattern":"match NaiveDateTime::try_from_value_encoding(bytes) {\n    Ok(ts) => ts,\n    Err(ValueEncodingError::InvalidTimestampEncoding(secs, nsecs)) => {\n        return Err(anyhow!(\"bad timestamp secs={secs} nsecs={nsecs}\"));\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Convert epoch millis/micros to (secs, nanos) before encoding timestamps","Keep nsecs under 1_000_000_000","Use consistent endianness and field order between writer and reader"],"tags":["value-encoding","timestamp","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"}