{"record":{"id":"fe59dd3599b159f3","repo":"nautechsystems/nautilus_trader","slug":"valid-utc-year-start","errorCode":null,"errorMessage":"valid UTC year start","messagePattern":"valid UTC year start","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/model/src/data/bar.rs","lineNumber":265,"sourceCode":"            start_time += origin_offset;\n\n            if now < start_time {\n                start_time -=\n                    duration_days(step.checked_mul(7).expect(\"`step` overflows i64 days\"));\n            }\n\n            start_time\n        }\n        BarAggregation::Month => {\n            // Set to the first day of the year\n            let now_civil = Offset::UTC.to_datetime(now);\n            let mut start_time = Offset::UTC\n                .to_timestamp(\n                    Date::new(now_civil.year(), 1, 1)\n                        .expect(\"valid year start date\")\n                        .at(0, 0, 0, 0),\n                )\n                .expect(\"valid UTC year start\");\n            start_time += origin_offset;\n\n            if now < start_time {\n                start_time =\n                    subtract_n_months(start_time, 12).expect(\"Failed to subtract 12 months\");\n            }\n\n            let months_step =\n                u32::try_from(step).expect(\"`step` exceeds u32 range for month arithmetic\");\n\n            while start_time <= now {\n                start_time =\n                    add_n_months(start_time, months_step).expect(\"Failed to add months in loop\");\n            }\n\n            start_time =\n                subtract_n_months(start_time, months_step).expect(\"Failed to subtract months_step\");\n            start_time","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/data/bar.rs#L247-L283","documentation":"Right after building Jan 1 midnight, the Month branch converts it to a timestamp: `Offset::UTC.to_timestamp(...).expect(\"valid UTC year start\")` (crates/model/src/data/bar.rs:265). It fails only if that civil datetime lies outside jiff's Timestamp-convertible range — not reachable for real Unix timestamps.","triggerScenarios":"Practically unreachable; requires the derived Jan-1 midnight to be outside jiff's supported timestamp range.","commonSituations":"Only from extreme synthetic inputs or a library bug.","solutions":["No action needed for genuine timestamps.","Check the `now` parameter for corruption if this panic occurs.","Upgrade the crate / file an issue if reproducible on real data."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// rust\nfn timestamp_in_reasonable_range(now: UnixNanos) -> bool {\n    let secs = now.as_u64() / 1_000_000_000;\n    secs > 0 && secs < 253_402_300_799\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass valid UnixNanos to bar start computations.","Treat any occurrence as a data-corruption or library bug to investigate."],"tags":["rust","panic","date-arithmetic","jiff","defensive"],"backgroundTag":"internal-invariant-violation","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"}