{"record":{"id":"3e2f22cade0b51f6","repo":"influxdata/influxdb","slug":"timestamp-out-of-range-for-precision","errorCode":null,"errorMessage":"timestamp, {}, out of range for precision: {:?}","messagePattern":"timestamp, (.+?), out of range for precision: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"influxdb3_types/src/write.rs","lineNumber":56,"sourceCode":"    ///\n    /// The method properly handles Precision::Auto which is meant to infer the units of\n    /// the timestamp, but doesn't apply if the default is being used.\n    ///\n    /// The returned value has units of nanoseconds in all cases.\n    pub fn to_nanos(\n        &self,\n        timestamp: Option<TimestampNoUnits>,\n        default_timestamp: Nanoseconds,\n    ) -> Result<Nanoseconds, anyhow::Error> {\n        debug_assert!(\n            default_timestamp >= 0,\n            \"in modern era, the default timestamp should be positive\"\n        );\n        match timestamp {\n            Some(ts) => {\n                let multiplier = self.infer_precision(ts).multiplier();\n                ts.checked_mul(multiplier).ok_or_else(|| {\n                    anyhow::anyhow!(\"timestamp, {}, out of range for precision: {:?}\", ts, self)\n                })\n            }\n            None => Ok(self.truncate_to_precision(default_timestamp)),\n        }\n    }\n\n    /// truncate_to_precision rounds the provided nanosecond value towards zero to a multiple\n    /// of precision. If it's auto, nanos is returned unchanged.\n    fn truncate_to_precision(&self, nanos: i64) -> i64 {\n        match self {\n            Precision::Auto => nanos,\n            precision => {\n                let multiplier = precision.multiplier();\n                (nanos / multiplier) * multiplier\n            }\n        }\n    }\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/influxdb3_types/src/write.rs#L38-L74","documentation":"Raised by to_nanos in influxdb3_types::write when converting a timestamp to nanoseconds would overflow for the inferred precision. The multiplier for the precision (s/ms/us/ns) is applied via checked_mul, and on overflow this anyhow error reports the timestamp and precision. It prevents silently wrapping timestamps during write-path qualification (validate_and_qualify_v1_line).","triggerScenarios":"Writing a line-protocol point whose timestamp, after multiplying by the precision multiplier, exceeds i64 nanosecond range — e.g. a very large epoch timestamp with millisecond/microsecond/second precision, or DateTime values far beyond the supported modern era.","commonSituations":"Sending timestamps in the far future or far past (year >~2262 in ns, larger bounds for coarser precision), clients sending microseconds instead of nanoseconds while specifying a coarser precision, clock misconfiguration.","solutions":["Use nanosecond precision (precision=ns) or a timestamp already in valid nanosecond range","Clamp/validate timestamps client-side to the supported range before writing","Fix the client clock or timestamp-generation code producing out-of-range values"],"exampleFix":"// before\nlet lp = \"cpu,host=a usage=99 9999999999999999999\"; // overflows after multiplier\n// after\nlet ts_ns: i64 = ...; // validate ts_ns within supported range first\nassert!((MIN_VALID_NS..=MAX_VALID_NS).contains(&ts_ns));","handlingStrategy":"validation","validationCode":"const MIN_VALID_NS: i64 = -9223372036854775808;\nconst MAX_VALID_NS: i64 = 9223372036854775807;\nfn ts_in_range(ts: i64, multiplier: i64) -> bool {\n    ts.checked_mul(multiplier).is_some()\n}","typeGuard":"fn convertible_to_nanos(ts: i64, multiplier: i64) -> bool {\n    ts.checked_mul(multiplier).is_some()\n}","tryCatchPattern":"match result {\n    Ok(v) => v,\n    Err(e) if e.to_string().starts_with(\"timestamp\") => /* 422: timestamp out of range */,\n    Err(e) => return Err(e),\n}","preventionTips":["Validate timestamps against the supported range client-side before writes","Never mix precision units; be explicit about precision","Check server clock/time-source correctness"],"tags":["timestamp","overflow","write","line-protocol"],"backgroundTag":"value-out-of-range","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}