{"record":{"id":"19351fdf5e7c96bc","repo":"nautechsystems/nautilus_trader","slug":"valid-year-start-date","errorCode":null,"errorMessage":"valid year start date","messagePattern":"valid year start date","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/model/src/data/bar.rs","lineNumber":262,"sourceCode":"            let mut start_time = Offset::UTC\n                .to_timestamp(week_start_date.at(0, 0, 0, 0))\n                .expect(\"valid UTC week start\");\n            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","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/data/bar.rs#L244-L280","documentation":"In `get_time_bar_start` (crates/model/src/data/bar.rs:262), the Month branch anchors to Jan 1 of the current year: `Date::new(now_civil.year(), 1, 1).expect(\"valid year start date\")`. This panics if the year is outside jiff's supported calendar range (roughly -9999..9999), which cannot happen for real Unix timestamps.","triggerScenarios":"Effectively unreachable for valid timestamps; would require `now` to decode to a civil year outside jiff's Date range.","commonSituations":"Corrupted or synthetic clock values; no realistic production path.","solutions":["No action needed for real timestamps.","If hit, verify the `now` UnixTimestamp passed in is not corrupted.","Report to maintainers with the offending timestamp if encountered."],"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":["Ensure timestamps come from a trusted clock; corrupt timestamps can break date math.","Defensive check only; unreachable with valid timestamps."],"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"}