{"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/d28e26e048401c53cbb98cf2d6ab0cf1e98048ca/influxdb3_types/src/write.rs#L38-L74","documentation":"Precision::to_nanos converts a unit-less i64 timestamp to nanoseconds by multiplying by the precision multiplier (s=1_000_000_000, ms=1_000_000, us=1_000, ns=1) via checked_mul. With Precision::Auto the unit is guessed from the value's magnitude (thresholds chosen so guess-based conversion essentially never overflows); with an explicitly supplied precision, a raw value too large for the declared unit overflows i64 nanoseconds (the ~1677-09-21..2262-04-11 range) and returns this error.","triggerScenarios":"Writing line protocol with precision=s while the client actually sends nanosecond-epoch integers (1.7e18 * 1e9 overflows); any explicit precision where the values' real unit is finer than declared; or genuine timestamps outside the i64 nanosecond date range for the chosen unit.","commonSituations":"Client library configured with the wrong precision string; ETL jobs writing raw epoch values with a hard-coded unit; junk numerics (IDs, phone numbers) landing in the timestamp field.","solutions":["Match the write precision parameter to the actual unit of the integer values (e.g. precision=ns for ns-epoch integers)","Send RFC3339/ISO-8601 timestamp strings instead of raw integers when units are uncertain","Validate client-side that ts.checked_mul(multiplier) fits in i64 before writing","Cleanse sources that put non-time numeric data into the timestamp field"],"exampleFix":"# before: ns-epoch integers declared as seconds\nclient.write('m,t=1 v=2 1755350400000000000', precision='s')  # ns * 1e9 -> overflow\n\n# after\nclient.write('m,t=1 v=2 1755350400000000000', precision='ns')\n# or send RFC3339: m,t=1 v=2 2026-08-16T12:00:00Z\n","handlingStrategy":"validation","validationCode":"# Python client-side check before writing raw integer timestamps\nMULT = {'s': 10**9, 'ms': 10**6, 'us': 10**3, 'ns': 1}\nI64_MAX = 2**63 - 1\n\ndef ts_ok(ts: int, precision: str) -> bool:\n    return -I64_MAX <= ts * MULT[precision] <= I64_MAX\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer RFC3339 timestamp strings at API boundaries; let the server parse them","Set the precision parameter to the true unit of your integer timestamps and assert it in tests","Never route IDs or other large numerics into the timestamp field","Remember the supported range: 1677-09-21 to 2262-04-11 in nanoseconds"],"tags":["timestamp","precision","overflow","line-protocol","influxdb3"],"backgroundTag":"timestamp-precision-overflow","analyzedSha":"d28e26e048401c53cbb98cf2d6ab0cf1e98048ca","analyzedAt":"2026-08-16T19:53:34.623Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}