{"record":{"id":"bba37c92ede0be16","repo":"vectordotdev/vector","slug":"timestamp-out-of-range","errorCode":null,"errorMessage":"Timestamp out of range","messagePattern":"Timestamp out of range","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"lib/codecs/src/encoding/transformer.rs","lineNumber":212,"sourceCode":"            let timestamp = if let Value::Timestamp(ts) = log.value() {\n                Some(extract(ts))\n            } else {\n                None\n            };\n            if let Some(ts) = timestamp {\n                log.insert(&vrl::path::OwnedTargetPath::event_root(), ts.into());\n            }\n        }\n    }\n\n    fn apply_timestamp_format(&self, log: &mut LogEvent) {\n        if let Some(timestamp_format) = self.timestamp_format.as_ref() {\n            match timestamp_format {\n                TimestampFormat::Unix => self.format_timestamps(log, |ts| ts.timestamp()),\n                TimestampFormat::UnixMs => self.format_timestamps(log, |ts| ts.timestamp_millis()),\n                TimestampFormat::UnixUs => self.format_timestamps(log, |ts| ts.timestamp_micros()),\n                TimestampFormat::UnixNs => self.format_timestamps(log, |ts| {\n                    ts.timestamp_nanos_opt().expect(\"Timestamp out of range\")\n                }),\n                TimestampFormat::UnixFloat => self.format_timestamps(log, |ts| {\n                    NotNan::new(ts.timestamp_micros() as f64 / 1e6)\n                        .expect(\"this division will never produce a NaN\")\n                }),\n                // RFC3339 is the default serialization of a timestamp.\n                TimestampFormat::Rfc3339 => (),\n            }\n        }\n    }\n\n    /// Set the `except_fields` value.\n    ///\n    /// Returns `Err` if the new `except_fields` fail validation, i.e. are not mutually exclusive\n    /// with `only_fields`.\n    #[cfg(any(test, feature = \"test\"))]\n    pub fn set_except_fields(\n        &mut self,","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/codecs/src/encoding/transformer.rs#L194-L230","documentation":"Panic via `.expect(\"Timestamp out of range\")` in `Transformer::apply_timestamp_format` (lib/codecs/src/encoding/transformer.rs). When the codec's `timestamp_format = \"unix_ns\"`, each event timestamp is converted with `ts.timestamp_nanos_opt()`, which returns `None` when the instant cannot be represented as an i64 count of nanoseconds — roughly dates before 1678 or after 2262. The `expect` then panics inside the encoding pipeline, taking down the process mid-stream.","triggerScenarios":"An encoding config with `timestamp_format = \"unix_ns\"` plus an event whose timestamp falls outside the nanosecond-representable range: year 9999 test fixtures, sentinel/zero dates, or RFC3164 syslog timestamps with two-digit years resolved into the wrong century (e.g. interpreted as 2108+).","commonSituations":"Switching a sink's codec to `unix_ns` for a consumer that wants nanosecond precision, then ingesting malformed or far-future timestamps from test data, misconfigured device clocks, or date-parsing bugs upstream.","solutions":["Use a coarser format with wider range — `unix` (seconds), `unix_ms`, or `unix_us` — or `rfc3339`","Sanitize/clamp event timestamps in a VRL remap transform before the sink (e.g. bound them to 1970–2262)","Fix the upstream producer or parsing rule that creates out-of-range timestamps (two-digit-year syslog is a classic source)"],"exampleFix":"# before\n[sinks.out.encoding]\ntimestamp_format = \"unix_ns\"\n\n# after\n[sinks.out.encoding]\ntimestamp_format = \"unix_us\"","handlingStrategy":"validation","validationCode":"// Guard before encoding: only unix_ns-encodable timestamps reach the sink\nfn nanos_representable(ts: chrono::DateTime<chrono::Utc>) -> bool {\n    ts.timestamp_nanos_opt().is_some()\n}","typeGuard":"fn nanos_representable(ts: chrono::DateTime<chrono::Utc>) -> bool {\n    ts.timestamp_nanos_opt().is_some() // roughly 1678..=2262\n}","tryCatchPattern":null,"preventionTips":["Prefer unix_us/unix_ms or rfc3339 unless you truly need nanosecond precision","Clamp or drop out-of-range timestamps in a VRL remap before a unix_ns sink","Watch for two-digit-year (RFC3164) timestamps resolving into the far future; fix parsing upstream"],"tags":["rust","vector","timestamp","overflow","panic","codec","encoding"],"backgroundTag":"timestamp-overflow","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}