nautechsystems/nautilus_trader · info
valid week start
Error message
valid week start
What it means
In `get_time_bar_start` (crates/model/src/data/bar.rs:243), the Week branch computes the start of the ISO week by subtracting `days_from_monday` days from the current UTC date with jiff's `checked_sub`. The expect panics if that date arithmetic fails — practically only if the subtraction underflows jiff's supported date range (years roughly -9999..9999), which cannot occur for real timestamps.
Source
Thrown at crates/model/src/data/bar.rs:243
find_closest_smaller_time(now, origin_offset, SignedDuration::from_millis(step))
}
BarAggregation::Second => {
find_closest_smaller_time(now, origin_offset, SignedDuration::from_secs(step))
}
BarAggregation::Minute => {
find_closest_smaller_time(now, origin_offset, SignedDuration::from_mins(step))
}
BarAggregation::Hour => {
find_closest_smaller_time(now, origin_offset, SignedDuration::from_hours(step))
}
BarAggregation::Day => find_closest_smaller_time(now, origin_offset, duration_days(step)),
BarAggregation::Week => {
let now_civil = Offset::UTC.to_datetime(now);
let days_from_monday = i64::from(now_civil.weekday().to_monday_zero_offset());
let week_start_date = now_civil
.date()
.checked_sub(jiff::Span::new().days(days_from_monday))
.expect("valid week start");
let mut start_time = Offset::UTC
.to_timestamp(week_start_date.at(0, 0, 0, 0))
.expect("valid UTC week start");
start_time += origin_offset;
if now < start_time {
start_time -=
duration_days(step.checked_mul(7).expect("`step` overflows i64 days"));
}
start_time
}
BarAggregation::Month => {
// Set to the first day of the year
let now_civil = Offset::UTC.to_datetime(now);
let mut start_time = Offset::UTC
.to_timestamp(
Date::new(now_civil.year(), 1, 1)View on GitHub (pinned to 18893faf8b)
Solutions
- No action needed for real timestamps; if you construct `now` yourself, ensure it is a normal UnixTimestamp.
- If seen, inspect the timestamp passed into get_time_bar_start for corruption.
- Upgrade jiff / nautilus_model if this arises from a library version bug.
Defensive patterns
Strategy: type-guard
Validate before calling
// rust
fn timestamp_in_reasonable_range(now: UnixNanos) -> bool {
let (secs, _) = (now.as_u64() / 1_000_000_000, ());
secs > 0 && secs < 253_402_300_799 // 9999-12-31
} Prevention
- Ensure clock sources produce real Unix timestamps, not sentinel/corrupted values.
- This guard is defensive; no caller action normally required.
When it happens
Trigger: Effectively unreachable for valid Unix timestamps; would require `now` to be a timestamp whose UTC civil date is at/near jiff's minimum supported date so subtracting up to 6 days underflows.
Common situations: Corrupted or synthetic clock values near the extreme low end of representable time; otherwise never hit in production.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- valid UTC week start
- valid year start date
- valid UTC year start
- seconds timestamp should be within valid range
- seconds timestamp should be within valid range
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/68d2912b1be63984.
Report an issue: GitHub.