{"record":{"id":"f53787383c3c4d40","repo":"Hmbown/CodeWhale","slug":"cron-field-name-value-value-is-out-of-range-m","errorCode":null,"errorMessage":"CRON {field_name} value {value} is out of range {min}-{max}","messagePattern":"CRON (.+?) value (.+?) is out of range (.+?)-(.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":861,"sourceCode":"        self.0\n            .iter()\n            .find_map(|(name, value)| (*name == needle).then_some(*value))\n    }\n}\n\nfn parse_cron_atom(\n    raw: &str,\n    min: u32,\n    max: u32,\n    names: CronNameMap,\n    field_name: &str,\n) -> Result<u32> {\n    let value = names\n        .lookup(raw)\n        .or_else(|| raw.parse::<u32>().ok())\n        .ok_or_else(|| anyhow::anyhow!(\"Invalid CRON {field_name} value '{raw}'\"))?;\n    if !(min..=max).contains(&value) {\n        bail!(\"CRON {field_name} value {value} is out of range {min}-{max}\");\n    }\n    Ok(value)\n}\n\nfn weekday_to_cron(day: Weekday) -> u32 {\n    match day {\n        Weekday::Sun => 0,\n        Weekday::Mon => 1,\n        Weekday::Tue => 2,\n        Weekday::Wed => 3,\n        Weekday::Thu => 4,\n        Weekday::Fri => 5,\n        Weekday::Sat => 6,\n    }\n}\n\nfn days_in_month(year: i32, month: u32) -> u32 {\n    match month {","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/automation_manager.rs#L843-L879","documentation":"parse_cron_atom resolves each token via the field's name map (month and day-of-week names) or as u32, then enforces inclusive bounds: minute 0-59, hour 0-23, day-of-month 1-31, month 1-12, day-of-week 0-7 (7 normalizes to 0 = Sunday). Out-of-bound numbers such as minute 60, hour 24, month 0 or 13, and weekday 8 bail here.","triggerScenarios":"EXPR='60 * * * *'; '0 24 * * *'; '* * 0 * *' (day-of-month 0); '0 0 * 13 *'; '0 12 * * 8'.","commonSituations":"Off-by-one ports (24 for midnight, 60 for top of hour); assuming 1-indexed weekdays; typos in numeric fields.","solutions":["Use 0 for midnight (hours are 0-23, minutes 0-59)","Use weekday 0 or 7 for Sunday, 1-6 for Monday-Saturday","Day-of-month starts at 1 and month at 1","Dry-run the EXPR via parse_rrule"],"exampleFix":"// before (there is no hour 24)\nrrule = \"FREQ=CRON;EXPR=0 24 * * *\"\n\n// after (midnight)\nrrule = \"FREQ=CRON;EXPR=0 0 * * *\"","handlingStrategy":"validation","validationCode":"const CRON_BOUNDS: [(u32, u32); 5] = [(0, 59), (0, 23), (1, 31), (1, 12), (0, 7)];\n\nfn cron_values_in_bounds(expr: &str) -> bool {\n    let fields: Vec<&str> = expr.split_whitespace().collect();\n    fields.len() == 5\n        && fields.iter().enumerate().all(|(i, f)| {\n            let (min, max) = CRON_BOUNDS[i];\n            f.split(',').all(|item| {\n                item.split('/').next().unwrap_or(item)\n                    .split('-')\n                    .all(|atom| atom.trim().parse::<u32>().is_ok_and(|v| v >= min && v <= max))\n            })\n        })\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember weekdays are 0-based with Sunday=0 (7 also accepted)","24:00 is not a valid hour; use 0","Use names (MON, JAN) to sidestep index confusion","Dry-run the full EXPR via parse_rrule"],"tags":["rust","cron","range","validation"],"backgroundTag":"cron-value-out-of-range","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}