Hmbown/CodeWhale · error

Invalid CRON value

Error message

Invalid CRON {field_name} value '{raw}'

What it means

Cron field guard in parse_cron_atom: the token for the named field is neither a recognized name (e.g. JAN/MON) nor a parseable unsigned integer. It fires on malformed atoms like 'X' or '9x' before the min..=max range check runs (out-of-range numeric values produce the other error).

Solutions

  1. Use a plain number or the field's accepted names (months weekdays) in the CRON field.
  2. Remove stray characters/whitespace from the atom.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/automation_manager.rs:958 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/1df34e8ae9be3894. Report an issue: GitHub.

Appendix: source

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

    fn lookup(self, token: &str) -> Option<u32> {
        let needle = token.trim().to_ascii_uppercase();
        self.0
            .iter()
            .find_map(|(name, value)| (*name == needle).then_some(*value))
    }
}

fn parse_cron_atom(
    raw: &str,
    min: u32,
    max: u32,
    names: CronNameMap,
    field_name: &str,
) -> Result<u32> {
    let value = names
        .lookup(raw)
        .or_else(|| raw.parse::<u32>().ok())
        .ok_or_else(|| anyhow::anyhow!("Invalid CRON {field_name} value '{raw}'"))?;
    if !(min..=max).contains(&value) {
        bail!("CRON {field_name} value {value} is out of range {min}-{max}");
    }
    Ok(value)
}

fn weekday_to_cron(day: Weekday) -> u32 {
    match day {
        Weekday::Sun => 0,
        Weekday::Mon => 1,
        Weekday::Tue => 2,
        Weekday::Wed => 3,
        Weekday::Thu => 4,
        Weekday::Fri => 5,
        Weekday::Sat => 6,
    }
}

View on GitHub (pinned to 73e0f67d83)