Hmbown/CodeWhale · error · anyhow::Error
BYHOUR must be between 0 and 23
Error message
BYHOUR must be between 0 and 23
What it means
RRULE validation for HOURLY automations: the BYHOUR part must denote a valid hour of day; a parsed value outside 0..23 is rejected before the schedule is stored, since no wall-clock hour could match it.
Solutions
- Use BYHOUR between 0 and 23 (midnight is 0, not 24)
- Clamp/normalize the hour value in the UI or config writer before saving
- Omit BYHOUR if no specific anchor hour is needed
Example fix
// before RRULE:FREQ=HOURLY;INTERVAL=4;BYHOUR=24 // after RRULE:FREQ=HOURLY;INTERVAL=4;BYHOUR=0
Defensive patterns
Strategy: validation
Validate before calling
const m = rule.match(/BYHOUR=(\d+)/);
if (m && Number(m[1]) > 23) throw new Error("BYHOUR must be between 0 and 23"); Type guard
function isValidHour(h: number): boolean { return Number.isInteger(h) && h >= 0 && h <= 23; } Try / catch
try {
parse_rrule(rule)?;
} catch e if e.to_string().contains("BYHOUR must be between 0 and 23") {
eprintln!("{e}; use 0-23 (midnight = 0)");
} Prevention
- Constrain hour inputs to 0-23 in the UI
- Convert 24:00-style input to 0 before serializing
- After timezone shifts, normalize hours with modulo 24
When it happens
Trigger: Parsing 'RRULE:FREQ=HOURLY;BYHOUR=24' or 'BYHOUR=99' — parse succeeds, range check fails.
Common situations: Off-by-one 24:00 time notation; user entering military-time 24 for midnight instead of 0.
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
- BYMINUTE must be between 0 and 59
- INTERVAL must be >= 1 for HOURLY schedules
- BYDAY cannot be empty for WEEKLY schedules
- Invalid BYDAY value
- RRULE must include FREQ
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/5ab5da019b8ab3fd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/automation_manager.rs:406
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 73e0f67d83)