Hmbown/CodeWhale · error

WEEKLY schedules require BYHOUR

Error message

WEEKLY schedules require BYHOUR

What it means

RRULE parse guard for WEEKLY frequency: after checking that only FREQ/BYDAY/BYHOUR/BYMINUTE keys are present, the BYHOUR key is absent from the parts map. WEEKLY schedules pin their anchor time via BYHOUR, so the field is mandatory here (BYDAY's own error fires first when it is missing).

Solutions

  1. Add BYHOUR to the RRULE, e.g. FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0
  2. Ensure BYHOUR is a plain integer 0-23 (no leading '+', no 'Z' suffix)
  3. Include BYMINUTE too — it is also required for WEEKLY

Example fix

// before
"FREQ=WEEKLY;BYDAY=MO"
// after
"FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0"
Defensive patterns

Strategy: validation

Validate before calling

fn validate_weekly_time(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(()); }
    let h: u32 = parts.get("BYHOUR").ok_or("WEEKLY requires BYHOUR")?.parse().map_err(|_| "BYHOUR not numeric")?;
    if h > 23 { return Err("BYHOUR must be 0-23".into()); }
    Ok(())
}

Try / catch

match parse_rrule(&rule) {
    Ok(s) => save(s),
    Err(e) if e.to_string().contains("require BYHOUR") =>
        eprintln!("Add BYHOUR (0-23) to your WEEKLY rule"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Submitting a WEEKLY RRULE like 'FREQ=WEEKLY;BYDAY=MO' with no BYHOUR key, or a non-numeric BYHOUR that failed earlier parsing surfaced as missing.

Common situations: Schedule authored from an iCal snippet that omitted time-of-day fields, timezone assumption that a default hour exists, copy-paste dropping the BYHOUR segment.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

            }
            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 73e0f67d83)