Hmbown/CodeWhale · error

Unable to round CRON search start

Error message

Unable to round CRON search start

What it means

WEEKLY next-run search: rounding the search start to a candidate local datetime failed (resolve_local_datetime returned None, typically a DST gap), so no valid next occurrence can be computed and the scheduler refuses rather than guessing a shifted time.

Solutions

  1. Check the CRON expression's fields (especially hour/minute/dom/month wildcards) for values that prevent rounding a valid local candidate after 'after'.
  2. Simplify the expression to isolate the offending field, then re-test next_run computation.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/automation_manager.rs:585 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/c217538dcdf4fe7d. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/automation_manager.rs:585

                    }
                    let Some(candidate_naive) = date.and_hms_opt(*byhour, *byminute, 0) else {
                        continue;
                    };
                    if let Some(candidate) = resolve_local_datetime(timezone, candidate_naive)
                        && candidate.with_timezone(&Utc) > after
                    {
                        return Ok(candidate.with_timezone(&Utc));
                    }
                }
                bail!("Unable to compute next WEEKLY run");
            }
            Self::Cron { expr } => {
                let cron = ParsedCronExpr::parse(expr)?;
                let mut candidate_naive = local_after
                    .naive_local()
                    .with_second(0)
                    .and_then(|dt| dt.with_nanosecond(0))
                    .ok_or_else(|| anyhow::anyhow!("Unable to round CRON search start"))?
                    .checked_add_signed(Duration::minutes(1))
                    .ok_or_else(|| anyhow::anyhow!("CRON schedule exceeded its range"))?;

                for _ in 0..MAX_CRON_SEARCH_MINUTES {
                    if cron.matches(candidate_naive)
                        && let Some(candidate) = resolve_local_datetime(timezone, candidate_naive)
                    {
                        let candidate = candidate.with_timezone(&Utc);
                        if candidate > after {
                            return Ok(candidate);
                        }
                    }
                    candidate_naive = candidate_naive
                        .checked_add_signed(Duration::minutes(1))
                        .ok_or_else(|| anyhow::anyhow!("CRON schedule exceeded its range"))?;
                }
                bail!("Unable to compute next CRON run within 5 years");
            }

View on GitHub (pinned to 73e0f67d83)