Hmbown/CodeWhale · error

WEEKLY schedules require BYHOUR

Error message

WEEKLY schedules require BYHOUR

What it means

AutomationSchedule::parse_rrule requires WEEKLY schedules to pin the fire hour via BYHOUR. BYDAY is checked first, so this error means BYDAY parsed fine but the BYHOUR key is absent; WEEKLY supports only FREQ,BYDAY,BYHOUR,BYMINUTE and the hour cannot default.

Source

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

            }
            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");
                }
                if byminute > 59 {
                    bail!("BYMINUTE must be between 0 and 59");
                }

                Ok(Self::Weekly {
                    byday,
                    byhour,

View on GitHub (pinned to 8880682c63)

Solutions

  1. Add BYHOUR as 0-23: FREQ=WEEKLY;BYDAY=MO,WE;BYHOUR=9;BYMINUTE=30
  2. Note the value must parse as u32 and be <= 23, or you get the follow-up 'BYHOUR must be between 0 and 23' error
  3. Validate with parse_rrule before persisting the automation

Example fix

// before
let rrule = "FREQ=WEEKLY;BYDAY=MO,WE;BYMINUTE=30";
// after
let rrule = "FREQ=WEEKLY;BYDAY=MO,WE;BYHOUR=9;BYMINUTE=30";
Defensive patterns

Strategy: validation

Validate before calling

let parts: std::collections::BTreeMap<&str, &str> = rrule
    .split(';')
    .filter_map(|kv| kv.split_once('='))
    .collect();
if parts.get("FREQ").copied() == Some("WEEKLY") {
    let byhour = parts.get("BYHOUR").context("WEEKLY requires BYHOUR")?;
    let hour: u32 = byhour.parse().context("BYHOUR must be numeric")?;
    ensure!(hour <= 23, "BYHOUR must be 0-23");
}

Type guard

fn weekly_rrule_has_valid_byhour(rrule: &str) -> bool {
    rrule.split(';').any(|kv| {
        let (k, v) = kv.split_once('=').unwrap_or(("", ""));
        k.eq_ignore_ascii_case("FREQ") && v.eq_ignore_ascii_case("WEEKLY")
    }) && rrule
        .split(';')
        .find_map(|kv| kv.split_once('=').filter(|(k, _)| k == "BYHOUR").map(|(_, v)| v))
        .and_then(|v| v.parse::<u32>().ok())
        .is_some_and(|h| h <= 23)
}

Prevention

When it happens

Trigger: An automation rrule like 'FREQ=WEEKLY;BYDAY=MO;BYMINUTE=30' (BYHOUR omitted) reaching AutomationSchedule::parse_rrule through automation create/update or the runtime API.

Common situations: Copying a weekly RRULE that was truncated; assuming BYHOUR defaults like it does for HOURLY anchors (it does not: WEEKLY requires it); editing a stored rrule by hand and dropping the field.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/f7154d5dbb575ad8. Report an issue: GitHub.