Hmbown/CodeWhale · error · anyhow::Error

Unsupported RRULE field

Error message

Unsupported RRULE field '{key}' for CRON. Allowed: FREQ,EXPR

What it means

parse_cron_schedule whitelists the RRULE keys allowed for a CRON schedule: only FREQ and EXPR. Any other key bails with this message naming the allowed set. This rejects, for example, BYDAY or INTERVAL on a cron schedule, since cron semantics are fully expressed by the five-field EXPR.

Solutions

  1. Keep only FREQ and EXPR in the CRON RRULE; encode day/hour restrictions inside the five-field EXPR.
  2. Remove leftover ONCE (AT) or recurring (BYDAY/INTERVAL) fields.
  3. Use FREQ=WEEKLY if you want the RRULE-style fields instead of cron syntax.

Example fix

// before
FREQ=CRON;EXPR="0 9 * * *";BYDAY=MO
// after
FREQ=CRON;EXPR="0 9 * * 1"
Defensive patterns

Strategy: validation

Validate before calling

const CRON_KEYS: [&str; 2] = ["FREQ", "EXPR"];
if !parts.keys().all(|k| CRON_KEYS.contains(&k.as_str())) {
    return Err("CRON schedules allow only FREQ and EXPR");
}

Try / catch

match AutomationSchedule::parse(rrule) {
    Ok(s) => save(s),
    Err(e) if e.to_string().contains("for CRON") => strip_unknown_fields_and_retry(),
    Err(e) => report(e),
}

Prevention

When it happens

Trigger: AutomationSchedule::parse with FREQ=CRON plus any key besides EXPR — e.g. FREQ=CRON;EXPR="0 9 * * *";BYDAY=MO or a leftover AT field from a ONCE schedule.

Common situations: Migrating a schedule between ONCE and CRON and forgetting to drop the old field; appending iCalendar-style fields to a cron RRULE.

Related errors


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

Appendix: source

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

}

fn parse_once_schedule(parts: &BTreeMap<String, String>) -> Result<AutomationSchedule> {
    for key in parts.keys() {
        if key != "FREQ" && key != "AT" {
            bail!("Unsupported RRULE field '{key}' for ONCE. Allowed: FREQ,AT");
        }
    }
    let raw_at = parts
        .get("AT")
        .ok_or_else(|| anyhow::anyhow!("ONCE schedules require AT"))?;
    let at = parse_once_at(raw_at)?;
    Ok(AutomationSchedule::Once { at })
}

fn parse_cron_schedule(parts: &BTreeMap<String, String>) -> Result<AutomationSchedule> {
    for key in parts.keys() {
        if key != "FREQ" && key != "EXPR" {
            bail!("Unsupported RRULE field '{key}' for CRON. Allowed: FREQ,EXPR");
        }
    }
    let expr = parts
        .get("EXPR")
        .map(|value| value.trim().to_string())
        .filter(|value| !value.is_empty())
        .ok_or_else(|| anyhow::anyhow!("CRON schedules require EXPR"))?;
    ParsedCronExpr::parse(&expr)?;
    Ok(AutomationSchedule::Cron { expr })
}

fn parse_once_at(raw: &str) -> Result<DateTime<Utc>> {
    let trimmed = raw.trim();
    if let Ok(at) = DateTime::parse_from_rfc3339(trimmed) {
        return Ok(at.with_timezone(&Utc));
    }
    for format in ["%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M"] {
        if let Ok(naive) = NaiveDateTime::parse_from_str(trimmed, format) {

View on GitHub (pinned to 73e0f67d83)