Hmbown/CodeWhale · error · anyhow::Error
BYHOUR must be between 0 and 23
Error message
BYHOUR must be between 0 and 23
What it means
In the HOURLY branch, an optional BYHOUR anchor must fit the 0–23 wall-clock hour range (parsed as u32, so anything above 23 fails, e.g. 24 or 99). BYHOUR here anchors the initial local wall-clock time; it is not a daily-only filter, so values beyond a valid hour are meaningless and rejected.
Source
Thrown at crates/tui/src/automation_manager.rs:351
if interval_hours == 0 {
bail!("INTERVAL must be >= 1 for HOURLY schedules");
}
let byday = parts
.get("BYDAY")
.map(|value| parse_byday(&value.to_ascii_uppercase()))
.transpose()?;
let anchor_hour = parts
.get("BYHOUR")
.map(|value| value.parse::<u32>())
.transpose()
.context("Failed to parse BYHOUR")?;
let anchor_minute = parts
.get("BYMINUTE")
.map(|value| value.parse::<u32>())
.transpose()
.context("Failed to parse BYMINUTE")?;
if anchor_hour.is_some_and(|hour| hour > 23) {
bail!("BYHOUR must be between 0 and 23");
}
if anchor_minute.is_some_and(|minute| minute > 59) {
bail!("BYMINUTE must be between 0 and 59");
}
Ok(Self::Hourly {
interval_hours,
byday,
anchor_hour,
anchor_minute,
})
}
AutomationFrequency::Weekly => {
for key in parts.keys() {
if key != "FREQ" && key != "BYDAY" && key != "BYHOUR" && key != "BYMINUTE" {
bail!(
"Unsupported RRULE field '{key}' for WEEKLY. Allowed: FREQ,BYDAY,BYHOUR,BYMINUTE"
);
}View on GitHub (pinned to 0c42157ee5)
Solutions
- Use a valid hour 0–23 (`BYHOUR=23` for 11 PM, not 24).
- If you need multiple fire hours, switch to `FREQ=CRON;EXPR=9,17 * * * *`.
- Range-check user-supplied hours before formatting the RRULE.
Example fix
// before
let s = AutomationSchedule::parse_rrule("FREQ=HOURLY;INTERVAL=24;BYHOUR=24")?; // bails: 0-23
// after
let s = AutomationSchedule::parse_rrule("FREQ=HOURLY;INTERVAL=24;BYHOUR=23")?; Defensive patterns
Strategy: validation
Validate before calling
let hour: u32 = hour_input;
assert!(hour <= 23, "BYHOUR must be 0-23");
let rrule = format!("FREQ=HOURLY;INTERVAL=6;BYHOUR={hour}"); Type guard
fn valid_hour(h: u32) -> bool { h <= 23 } Try / catch
match AutomationSchedule::parse_rrule(&rrule) {
Ok(s) => s,
Err(e) if e.to_string().starts_with("BYHOUR must be between 0 and 23") => { /* re-prompt for a 0-23 hour */ return Err(e) }
Err(e) => return Err(e),
} Prevention
- Use 0–23 hours; 24 is never valid (use 0).
- Validate hour fields at the form/config boundary.
- Convert 12-hour AM/PM input to 24-hour before formatting.
When it happens
Trigger: parse_rrule("FREQ=HOURLY;INTERVAL=6;BYHOUR=24") or BYHOUR=25/830 in a HOURLY rule.
Common situations: Using 24 to mean end-of-day; off-by-one from thinking hours are 1–24; RFC 5545 BYHOUR lists like `BYHOUR=9,17` being pasted in (the comma makes it fail u32 parsing first, but single out-of-range values hit this check).
Related errors
- Invalid RRULE segment '{item}'
- Unsupported RRULE FREQ '{other}'. Supported: ONCE, HOURLY, W
- RRULE must include FREQ
- Unsupported RRULE field '{key}' for HOURLY. Allowed: FREQ,IN
- INTERVAL must be >= 1 for HOURLY schedules
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/5ab5da019b8ab3fd.
Report an issue: GitHub.