{"record":{"id":"aad26c6591640e49","repo":"nautechsystems/nautilus_trader","slug":"binance-field-timestamp-is-outside-the-unixnanos","errorCode":null,"errorMessage":"Binance {field} timestamp is outside the UnixNanos range: {value}","messagePattern":"Binance (.+?) timestamp is outside the UnixNanos range: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/parse.rs","lineNumber":92,"sourceCode":"\npub(crate) fn parse_millis(value: i64, field: &str) -> anyhow::Result<UnixNanos> {\n    parse_timestamp(value, UnixNanos::from_millis_checked(value), field)\n}\n\npub(crate) fn parse_micros(value: i64, field: &str) -> anyhow::Result<UnixNanos> {\n    parse_timestamp(value, UnixNanos::from_micros_checked(value), field)\n}\n\nfn parse_timestamp(\n    value: i64,\n    timestamp: Option<UnixNanos>,\n    field: &str,\n) -> anyhow::Result<UnixNanos> {\n    timestamp.ok_or_else(|| {\n        if value < 0 {\n            anyhow::anyhow!(\"invalid negative Binance {field} timestamp: {value}\")\n        } else {\n            anyhow::anyhow!(\"Binance {field} timestamp is outside the UnixNanos range: {value}\")\n        }\n    })\n}\n\npub(crate) fn parse_millis_or_init(value: i64, field: &str, ts_init: UnixNanos) -> UnixNanos {\n    timestamp_or_init(parse_millis(value, field), ts_init)\n}\n\npub(crate) fn parse_micros_or_init(value: i64, field: &str, ts_init: UnixNanos) -> UnixNanos {\n    timestamp_or_init(parse_micros(value, field), ts_init)\n}\n\nfn timestamp_or_init(timestamp: anyhow::Result<UnixNanos>, ts_init: UnixNanos) -> UnixNanos {\n    match timestamp {\n        Ok(timestamp) => timestamp,\n        Err(e) => {\n            log::warn!(\"{e}; using initialization timestamp\");\n            ts_init","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/parse.rs#L74-L110","documentation":"parse_timestamp converts an i64 epoch value into UnixNanos; when the conversion result is None because the value (a non-negative, typically very large millisecond/microsecond value) exceeds what UnixNanos can represent, this 'outside the UnixNanos range' error is raised.","triggerScenarios":"Calling parse_millis or parse_micros with an i64 so large that converting to UnixNanos (nanosecond precision) overflows — e.g. microsecond timestamps far in the future, garbage values, or misread fields where a non-timestamp number is passed as a timestamp.","commonSituations":"Passing microseconds where milliseconds are expected (or vice versa) is usually safe, but absurd/future values from corrupted data or sentinel values like i64::MAX trigger this; unit tests using arbitrary large numbers.","solutions":["Verify you are passing the correct field and unit (millis vs micros) from the Binance response.","Sanity-check the raw value is a plausible epoch time before parsing.","Fix corrupted upstream data or fixtures containing huge values.","Use parse_millis_or_init if a fallback ts_init is acceptable for invalid values."],"exampleFix":"// before\nlet ts = parse_micros(i64::MAX, \"time\")?;\n\n// after\nlet ts = parse_millis(raw_time, \"time\")?; // correct unit and real field value","handlingStrategy":"validation","validationCode":"fn is_plausible_ts(v: i64) -> bool { v >= 0 && v < 4_102_444_800_000 } // millis bound\n// micros: use parse_micros only for genuinely microsecond fields","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm millis vs micros for each Binance field before parsing.","Sanity-check values against the current wall clock.","Use parse_millis_or_init for tolerant fallback behavior."],"tags":["binance","timestamp","overflow","parsing"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}