{"record":{"id":"3bc868499d862889","repo":"nautechsystems/nautilus_trader","slug":"seconds-timestamp-should-be-within-valid-range-3bc868","errorCode":null,"errorMessage":"seconds timestamp should be within valid range","messagePattern":"seconds timestamp should be within valid range","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/generators/order_list_id.rs","lineNumber":148,"sourceCode":"}\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}\n\n#[cfg(test)]","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/generators/order_list_id.rs#L130-L166","documentation":"This panic comes from `Timestamp::from_second(...).expect(\"seconds timestamp should be within valid range\")` in `write_fixed_prefix` in crates/common/src/generators/order_list_id.rs. The epoch value fit in i64 but jiff only accepts timestamps within roughly -9999..9999 years (i64 seconds in range -377705023201..253402300799), so an out-of-range i64 second value is rejected and the expect panics.","triggerScenarios":"Calling `refresh_fixed_prefix` with an epoch_second that converts to an i64 outside jiff's valid timestamp range — e.g. values beyond year 9999 or before year -9999 (negative seconds below -377705023201, or above 253402300799).","commonSituations":"Mock clocks or generated test values using i64::MAX/MIN, bad deserialization of timestamps, or clock misconfiguration producing absurd epoch values passed into the OrderListId generator.","solutions":["Validate the epoch seconds are within jiff's supported range before calling: `-377705023201 <= secs <= 253402300799`","Fix the clock source to return real current Unix seconds","In tests, use a fixed realistic timestamp fixture rather than i64 extremes"],"exampleFix":"// before\nlet secs: i64 = i64::MAX; // out of jiff range\ngenerator.refresh_fixed_prefix(u64::try_from(secs).unwrap());\n// after\nconst MIN_SECS: i64 = -377705023201;\nconst MAX_SECS: i64 = 253402300799;\nassert!((MIN_SECS..=MAX_SECS).contains(&secs), \"epoch seconds out of representable range\");\ngenerator.refresh_fixed_prefix(u64::try_from(secs).unwrap());","handlingStrategy":"validation","validationCode":"fn in_jiff_range(secs: i64) -> bool { (-377705023201..=253402300799).contains(&secs) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm timestamp units (seconds vs millis vs nanos) at boundaries","Check jiff's documented valid timestamp range before converting","Use fixed realistic fixtures in tests instead of i64 extremes"],"tags":["rust","panic","timestamp","jiff"],"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-14T05:17:10.506Z"}