{"record":{"id":"5ab5da019b8ab3fd","repo":"Hmbown/CodeWhale","slug":"byhour-must-be-between-0-and-23","errorCode":null,"errorMessage":"BYHOUR must be between 0 and 23","messagePattern":"BYHOUR must be between 0 and 23","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":351,"sourceCode":"                if interval_hours == 0 {\n                    bail!(\"INTERVAL must be >= 1 for HOURLY schedules\");\n                }\n                let byday = parts\n                    .get(\"BYDAY\")\n                    .map(|value| parse_byday(&value.to_ascii_uppercase()))\n                    .transpose()?;\n                let anchor_hour = parts\n                    .get(\"BYHOUR\")\n                    .map(|value| value.parse::<u32>())\n                    .transpose()\n                    .context(\"Failed to parse BYHOUR\")?;\n                let anchor_minute = parts\n                    .get(\"BYMINUTE\")\n                    .map(|value| value.parse::<u32>())\n                    .transpose()\n                    .context(\"Failed to parse BYMINUTE\")?;\n                if anchor_hour.is_some_and(|hour| hour > 23) {\n                    bail!(\"BYHOUR must be between 0 and 23\");\n                }\n                if anchor_minute.is_some_and(|minute| minute > 59) {\n                    bail!(\"BYMINUTE must be between 0 and 59\");\n                }\n                Ok(Self::Hourly {\n                    interval_hours,\n                    byday,\n                    anchor_hour,\n                    anchor_minute,\n                })\n            }\n            AutomationFrequency::Weekly => {\n                for key in parts.keys() {\n                    if key != \"FREQ\" && key != \"BYDAY\" && key != \"BYHOUR\" && key != \"BYMINUTE\" {\n                        bail!(\n                            \"Unsupported RRULE field '{key}' for WEEKLY. Allowed: FREQ,BYDAY,BYHOUR,BYMINUTE\"\n                        );\n                    }","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/automation_manager.rs#L333-L369","documentation":"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.","triggerScenarios":"parse_rrule(\"FREQ=HOURLY;INTERVAL=6;BYHOUR=24\") or BYHOUR=25/830 in a HOURLY rule.","commonSituations":"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).","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."],"exampleFix":"// before\nlet s = AutomationSchedule::parse_rrule(\"FREQ=HOURLY;INTERVAL=24;BYHOUR=24\")?; // bails: 0-23\n\n// after\nlet s = AutomationSchedule::parse_rrule(\"FREQ=HOURLY;INTERVAL=24;BYHOUR=23\")?;","handlingStrategy":"validation","validationCode":"let hour: u32 = hour_input;\nassert!(hour <= 23, \"BYHOUR must be 0-23\");\nlet rrule = format!(\"FREQ=HOURLY;INTERVAL=6;BYHOUR={hour}\");","typeGuard":"fn valid_hour(h: u32) -> bool { h <= 23 }","tryCatchPattern":"match AutomationSchedule::parse_rrule(&rrule) {\n    Ok(s) => s,\n    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) }\n    Err(e) => return Err(e),\n}","preventionTips":["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."],"tags":["rrule","automation","schedule","hour-range"],"backgroundTag":"rrule-hour-out-of-range","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}