Hmbown/CodeWhale · error

WEEKLY schedules require BYDAY

Error message

WEEKLY schedules require BYDAY

What it means

The automation RRULE parser enforces a restricted WEEKLY recurrence grammar: FREQ, BYDAY, BYHOUR, BYMINUTE. A WEEKLY rule without a BYDAY field cannot resolve which weekdays to fire on, so parsing fails with this error.

Solutions

  1. Add BYDAY to the RRULE, e.g. FREQ=WEEKLY;BYDAY=MO,WE;BYHOUR=9;BYMINUTE=0
  2. Remove unsupported fields (INTERVAL, COUNT, WKST, UNTIL) — only FREQ,BYDAY,BYHOUR,BYMINUTE are allowed
  3. Use FREQ=DAILY instead if the intent was every-day recurrence
  4. Validate the RRULE string against the documented WEEKLY grammar before saving

Example fix

// before
"FREQ=WEEKLY;BYHOUR=9;BYMINUTE=30"
// after
"FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;BYHOUR=9;BYMINUTE=30"
Defensive patterns

Strategy: validation

Validate before calling

fn validate_weekly_rrule(rule: &str) -> Result<(), String> {
    let parts: HashMap<_,_> = rule.split(';').filter_map(|p| p.split_once('=')).collect();
    if parts.get("FREQ").map(String::as_str) != Some("WEEKLY") { return Ok(()); }
    if !parts.contains_key("BYDAY") { return Err("WEEKLY schedules require BYDAY".into()); }
    Ok(())
}

Try / catch

match parse_rrule(&rule) {
    Ok(schedule) => save(schedule),
    Err(e) if e.to_string().contains("require BYDAY") =>
        eprintln!("Add BYDAY (e.g. BYDAY=MO,WE) to your WEEKLY rule"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Registering or updating an automation whose schedule is e.g. 'FREQ=WEEKLY;BYHOUR=9;BYMINUTE=0' with no BYDAY key, or using an unsupported field that caused BYDAY to be dropped.

Common situations: Config copied from a full iCalendar RRULE using INTERVAL/COUNT/WKST, hand-written schedule missing BYDAY, migration from a scheduler that implied daily recurrence without BYDAY.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

                }
                Ok(Self::Hourly {
                    interval_hours,
                    byday,
                    anchor_hour,
                    anchor_minute,
                })
            }
            AutomationFrequency::Weekly => {
                for key in parts.keys() {
                    if key != "FREQ" && key != "BYDAY" && key != "BYHOUR" && key != "BYMINUTE" {
                        bail!(
                            "Unsupported RRULE field '{key}' for WEEKLY. Allowed: FREQ,BYDAY,BYHOUR,BYMINUTE"
                        );
                    }
                }
                let byday_raw = parts
                    .get("BYDAY")
                    .ok_or_else(|| anyhow::anyhow!("WEEKLY schedules require BYDAY"))?;
                let byday = parse_byday(&byday_raw.to_ascii_uppercase())?;
                if byday.is_empty() {
                    bail!("BYDAY cannot be empty for WEEKLY schedules");
                }
                let byhour = parts
                    .get("BYHOUR")
                    .ok_or_else(|| anyhow::anyhow!("WEEKLY schedules require BYHOUR"))?
                    .parse::<u32>()
                    .context("Failed to parse BYHOUR")?;
                let byminute = parts
                    .get("BYMINUTE")
                    .ok_or_else(|| anyhow::anyhow!("WEEKLY schedules require BYMINUTE"))?
                    .parse::<u32>()
                    .context("Failed to parse BYMINUTE")?;

                if byhour > 23 {
                    bail!("BYHOUR must be between 0 and 23");
                }

View on GitHub (pinned to 73e0f67d83)