Hmbown/CodeWhale · error
Unable to construct HOURLY anchor
Error message
Unable to construct HOURLY anchor
What it means
When computing the next run of a HOURLY automation, the code builds an anchor datetime from the anchor date plus (hour, minute, 0) via chrono's and_hms_opt; if that combination is invalid (impossible time-of-day) construction fails with this error.
Solutions
- Fix the schedule's hour/minute values to hour 0-23 and minute 0-59
- Validate BYHOUR/BYMINUTE ranges at schedule-creation time before persisting
- Re-save the automation through the UI/CLI so values are range-checked
Example fix
// before: unvalidated config
{ "freq": "HOURLY", "intervalHours": 2, "hour": 24, "minute": 0 }
// after: validate before use
assert!((0..=23).contains(&hour) && (0..=59).contains(&minute), "invalid HOURLY anchor time"); Defensive patterns
Strategy: validation
Validate before calling
fn valid_hourly_time(hour: u32, minute: u32) -> bool {
hour <= 23 && minute <= 59
}
// call before creating/updating a HOURLY automation
if !valid_hourly_time(hour, minute) { bail!("HOURLY time out of range"); } Type guard
fn is_valid_time(t: &(u32, u32)) -> bool { t.0 <= 23 && t.1 <= 59 } Try / catch
match next_run(&schedule, after) {
Ok(r) => r,
Err(e) if e.to_string().contains("Unable to construct HOURLY anchor") => {
eprintln!("Schedule time-of-day invalid; fix hour/minute in config");
ScheduleError::BadAnchor
}
Err(e) => return Err(e),
} Prevention
- Validate hour 0-23 and minute 0-59 at schedule creation
- Never write raw hour/minute values from untrusted input into schedule config
- Add a config-load check that rejects impossible times early (fail loud)
- Round-trip test schedules after editing config by hand
When it happens
Trigger: A HOURLY schedule whose configured hour or minute is out of the valid range (hour > 23 or minute > 59), producing None from and_hms_opt; the anchor date itself is valid, so only the time fields can be at fault.
Common situations: Hand-edited schedule config with BYHOUR=24 or BYMINUTE=60, config written by another tool with overflow values, timezone anchor reference combined with unvalidated user input.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- HOURLY schedule exceeded its range
- Claimed delayed trigger has no durable task binding
- Once schedule has no future run after
- Unable to compute next anchored HOURLY run
- Unable to compute next HOURLY run for BYDAY filter
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/6a1ce4055a42df86.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/automation_manager.rs:499
"Once schedule has no future run after {}",
after.to_rfc3339()
)
}
}
Self::Hourly {
interval_hours,
byday,
anchor_hour,
anchor_minute,
} => {
if anchor_hour.is_some() || anchor_minute.is_some() {
let local_anchor_reference = anchor_reference.with_timezone(timezone);
let hour = anchor_hour.unwrap_or(local_anchor_reference.hour());
let minute = anchor_minute.unwrap_or(0);
let anchor_naive = local_anchor_reference
.date_naive()
.and_hms_opt(hour, minute, 0)
.ok_or_else(|| anyhow::anyhow!("Unable to construct HOURLY anchor"))?;
let interval_seconds = i64::from(*interval_hours) * 60 * 60;
let elapsed_seconds = local_after
.naive_local()
.signed_duration_since(anchor_naive)
.num_seconds();
let mut steps = if elapsed_seconds < 0 {
0
} else {
elapsed_seconds / interval_seconds + 1
};
for _ in 0..MAX_HOURLY_SEARCH_STEPS {
let hours = i64::from(*interval_hours)
.checked_mul(steps)
.ok_or_else(|| anyhow::anyhow!("HOURLY schedule exceeded its range"))?;
let delta = Duration::try_hours(hours)
.ok_or_else(|| anyhow::anyhow!("HOURLY schedule exceeded its range"))?;
let candidate_naive = anchor_naiveView on GitHub (pinned to 73e0f67d83)