{"record":{"id":"aa13d89babe9b52b","repo":"Hmbown/CodeWhale","slug":"unable-to-compute-next-cron-run-within-5-years","errorCode":null,"errorMessage":"Unable to compute next CRON run within 5 years","messagePattern":"Unable to compute next CRON run within 5 years","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":602,"sourceCode":"                    .and_then(|dt| dt.with_nanosecond(0))\n                    .ok_or_else(|| anyhow::anyhow!(\"Unable to round CRON search start\"))?\n                    .checked_add_signed(Duration::minutes(1))\n                    .ok_or_else(|| anyhow::anyhow!(\"CRON schedule exceeded its range\"))?;\n\n                for _ in 0..MAX_CRON_SEARCH_MINUTES {\n                    if cron.matches(candidate_naive)\n                        && let Some(candidate) = resolve_local_datetime(timezone, candidate_naive)\n                    {\n                        let candidate = candidate.with_timezone(&Utc);\n                        if candidate > after {\n                            return Ok(candidate);\n                        }\n                    }\n                    candidate_naive = candidate_naive\n                        .checked_add_signed(Duration::minutes(1))\n                        .ok_or_else(|| anyhow::anyhow!(\"CRON schedule exceeded its range\"))?;\n                }\n                bail!(\"Unable to compute next CRON run within 5 years\");\n            }\n        }\n    }\n\n    fn next_after_slot(\n        &self,\n        slot: DateTime<Utc>,\n        anchor_reference: DateTime<Utc>,\n    ) -> Result<Option<DateTime<Utc>>> {\n        match self {\n            Self::Once { .. } => Ok(None),\n            _ => self\n                .next_after_with_anchor(slot, anchor_reference)\n                .map(Some),\n        }\n    }\n\n    /// First slot after `slot` that is still in the future at `now`.","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/automation_manager.rs#L584-L620","documentation":"Cron schedules are resolved by scanning minute-by-minute up to MAX_CRON_SEARCH_MINUTES (five years of minutes). If no minute in that window satisfies the parsed CRON expression and resolves to a real local time, the search bails with this message. It guards the matcher against expressions that can never match (e.g. February 30) from spinning forever.","triggerScenarios":"A CRON expression whose field combination can never be true — e.g. '0 0 30 2 *' (Feb 30) or '0 0 31 4 *' (Apr 31) — or an expression matching only instants that fall in DST gaps, so no minute within five years matches and resolves.","commonSituations":"Users porting cron entries with impossible day-of-month/month combinations; typos like day 32; expressions using February 29 style dates without leap-year alignment (29 Feb matches only in leap years — still fine unless combined so it never matches in the window).","solutions":["Fix the expression so it can match real dates (e.g. '0 0 30 2 *' → '0 0 28 2 *' or use '*' for day-of-month).","Verify each field's range: minute 0-59, hour 0-23, day-of-month 1-31, month 1-12, day-of-week 0-6.","If the date is genuinely rare (e.g. Feb 29), confirm the intended semantics; consider a WEEKLY/MONTHLY RRULE instead."],"exampleFix":"// before\nEXPR=\"0 0 30 2 *\"\n// after\nEXPR=\"0 0 28 2 *\"","handlingStrategy":"validation","validationCode":"fn cron_expr_can_match(expr: &str) -> bool {\n    // reject impossible day/month pairs like 30 Feb or 31 Apr\n    let f: Vec<&str> = expr.split_whitespace().collect();\n    f.len() == 5 && !(f[2] == \"30\" && f[3] == \"2\") && !(f[2] == \"31\" && [\"4\",\"6\",\"9\",\"11\"].contains(&f[3]))\n}","typeGuard":null,"tryCatchPattern":"match schedule.next_after_with_anchor(now, anchor) {\n    Ok(next) => arm(next),\n    Err(e) if e.to_string().contains(\"CRON run within 5 years\") => disable_schedule(\"expression never matches\"),\n    Err(e) => report(e),\n}","preventionTips":["Sanity-check day-of-month against the month at schedule creation.","Prefer '*' for day-of-month when constraining day-of-week (or vice versa).","Compute the next run once on save; failure means the expression is impossible."],"tags":["scheduling","cron","bounds"],"backgroundTag":"invalid-date-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}