{"record":{"id":"df0d9542f6d6b4dd","repo":"nautechsystems/nautilus_trader","slug":"timestamp-overflow-for-record","errorCode":null,"errorMessage":"Timestamp overflow for record","messagePattern":"Timestamp overflow for record","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/symbology.rs","lineNumber":145,"sourceCode":"        (msg.hd.instrument_id, msg.ts_recv)\n    } else if let Some(msg) = record.get::<dbn::StatMsg>() {\n        (msg.hd.instrument_id, msg.ts_recv)\n    } else if let Some(msg) = record.get::<dbn::InstrumentDefMsg>() {\n        (msg.hd.instrument_id, msg.ts_recv)\n    } else if let Some(msg) = record.get::<dbn::Cmbp1Msg>() {\n        (msg.hd.instrument_id, msg.ts_recv)\n    } else if let Some(msg) = record.get::<dbn::CbboMsg>() {\n        (msg.hd.instrument_id, msg.ts_recv)\n    } else if let Some(msg) = record.get::<dbn::TbboMsg>() {\n        (msg.hd.instrument_id, msg.ts_recv)\n    } else {\n        anyhow::bail!(\"DBN message type is not currently supported\")\n    };\n\n    let duration = time::Duration::nanoseconds(nanoseconds as i64);\n    let datetime = time::OffsetDateTime::UNIX_EPOCH\n        .checked_add(duration)\n        .ok_or_else(|| anyhow::anyhow!(\"Timestamp overflow for record\"))?;\n    let date = datetime.date();\n    let symbol_map = metadata.symbol_map_for_date(date)?;\n    let raw_symbol = symbol_map\n        .get(instrument_id)\n        .ok_or_else(|| anyhow::anyhow!(\"No raw symbol found for {instrument_id}\"))?;\n\n    let symbol = Symbol::from_str_unchecked(raw_symbol);\n\n    Ok(InstrumentId::new(symbol, venue))\n}\n\n#[must_use]\npub fn infer_symbology_type(symbol: &str) -> SType {\n    if symbol.ends_with(\".FUT\") || symbol.ends_with(\".OPT\") {\n        return SType::Parent;\n    }\n\n    let parts: Vec<&str> = symbol.split('.').collect();","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/symbology.rs#L127-L163","documentation":"get_nautilus_instrument_id_for_record converts the record's nanosecond timestamp into an OffsetDateTime to look up the symbology map for that date. If the nanosecond value overflows the representable range when added to the Unix epoch (checked_add returns None), the timestamp cannot be converted and this error is raised instead of panicking.","triggerScenarios":"A record carries an absurd ts_event/ts_recv nanosecond value (e.g. 0-sentinel misused, uninitialized memory decoded as a timestamp, or garbage after failed schema inference) that overflows i64::MAX nanoseconds past 1970.","commonSituations":"Corrupt or truncated DBN files decoded anyway; decoding a file of a different schema where a non-timestamp field is read as the timestamp; hand-rolled or patched record data with wrong epoch units (micros vs nanos shifted).","solutions":["Inspect the offending record's raw timestamp values (print the record before mapping) and fix or discard records with invalid timestamps.","Re-download the data file — the source is most likely corrupt or truncated.","Verify you are decoding with the matching DBN schema/version so fields are not misinterpreted.","Filter records by a sane ts range before decoding symbology (e.g. reject ts > now + margin or ts < dataset start)."],"exampleFix":"// before\nfor record in records { let id = get_nautilus_instrument_id_for_record(record, ...)?; }\n\n// after\nfor record in records.filter(|r| r.ts_event() > MIN_SANE_TS && r.ts_event() < MAX_SANE_TS) {\n    let id = get_nautilus_instrument_id_for_record(record, ...)?;\n}","handlingStrategy":"validation","validationCode":"// Rust\nconst MAX_NANOS: i64 = 4_102_444_800_000_000_000; // year 2100\nanyhow::ensure!(\n    nanoseconds > 0 && (nanoseconds as i64) < MAX_NANOS,\n    \"implausible record timestamp: {nanoseconds}\"\n);","typeGuard":null,"tryCatchPattern":"let id = match get_nautilus_instrument_id_for_record(record, metadata, venue) {\n    Ok(id) => id,\n    Err(e) if e.to_string().contains(\"Timestamp overflow\") => {\n        log::warn!(\"dropping record with corrupt timestamp\");\n        return Ok(None);\n    }\n    Err(e) => return Err(e.into()),\n};","preventionTips":["Validate file integrity before decoding (truncation often corrupts timestamps)","Filter records by a sane ts_event window before symbology mapping","Decode with the matching DBN schema version"],"tags":["databento","rust","timestamp","overflow"],"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-14T00:17:10.932Z"}