{"record":{"id":"ea41a3fc671d1486","repo":"nautechsystems/nautilus_trader","slug":"seconds-timestamp-should-fit-i64-ea41a3","errorCode":null,"errorMessage":"seconds timestamp should fit i64","messagePattern":"seconds timestamp should fit i64","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/generators/order_list_id.rs","lineNumber":146,"sourceCode":"        self.epoch_second = epoch_second;\n    }\n}\n\n#[inline]\nfn fixed_prefix_capacity(trader_tag: &str, strategy_tag: &str) -> usize {\n    \"OL-\".len()\n        + DATETIME_TAG_LEN\n        + \"-\".len()\n        + trader_tag.len()\n        + \"-\".len()\n        + strategy_tag.len()\n        + \"-\".len()\n}\n\nfn write_fixed_prefix(buf: &mut String, trader_tag: &str, strategy_tag: &str, epoch_second: u64) {\n    let now_utc = Offset::UTC.to_datetime(\n        Timestamp::from_second(\n            i64::try_from(epoch_second).expect(\"seconds timestamp should fit i64\"),\n        )\n        .expect(\"seconds timestamp should be within valid range\"),\n    );\n\n    buf.clear();\n\n    write!(\n        buf,\n        \"OL-{:04}{:02}{:02}-{:02}{:02}{:02}-{trader_tag}-{strategy_tag}-\",\n        now_utc.year(),\n        now_utc.month(),\n        now_utc.day(),\n        now_utc.hour(),\n        now_utc.minute(),\n        now_utc.second(),\n    )\n    .expect(\"writing to String should not fail\");\n}","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/generators/order_list_id.rs#L128-L164","documentation":"This panic comes from `i64::try_from(epoch_second).expect(...)` inside `write_fixed_prefix` in crates/common/src/generators/order_list_id.rs. The function builds a date-time prefix for generated OrderListId values from a Unix epoch seconds value, and jiff's `Timestamp::from_second` requires an i64. The generator treats an epoch_second that cannot fit in an i64 (or is otherwise unrepresentable) as a hard invariant violation and panics immediately.","triggerScenarios":"Calling `refresh_fixed_prefix` (directly or via OrderListIdGenerator refresh logic) with an `epoch_second: u64` value greater than i64::MAX (9,223,372,036,854,775,807). Only values above ~292 billion years from the epoch trigger this; a normal wall-clock value can never.","commonSituations":"Practically unreachable in production; seen when tests or fuzzing pass synthetic u64::MAX / huge mock clock values into the generator, or when an uninitialized/overflowing clock counter is fed in as epoch seconds.","solutions":["Verify the clock/timestamp source feeding epoch_second; use the real current time (e.g. `Timestamp::now().as_unix_seconds()` style) instead of a raw counter","Clamp or validate the u64 before calling: if `epoch_second > i64::MAX as u64`, reject or saturate it upstream","If this fires in tests, fix the test fixture to use a realistic epoch value instead of u64::MAX"],"exampleFix":"// before\nlet epoch = u64::MAX; // overflow value from fixture\nlet _ = generator.refresh_fixed_prefix(epoch);\n// after\nlet epoch = u64::try_from(std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs()).unwrap();\nassert!(epoch <= i64::MAX as u64);\nlet _ = generator.refresh_fixed_prefix(epoch);","handlingStrategy":"validation","validationCode":"fn valid_epoch_seconds(secs: u64) -> bool { secs <= i64::MAX as u64 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always derive epoch seconds from the system clock, never from raw counters","Range-check u64 timestamps before passing to APIs expecting i64"],"tags":["rust","panic","timestamp","integer-conversion"],"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"}