Hmbown/CodeWhale · error · anyhow::Error

BYDAY cannot be empty for WEEKLY schedules

Error message

BYDAY cannot be empty for WEEKLY schedules

What it means

WEEKLY schedules require a non-empty BYDAY list naming which weekdays the automation runs. BYDAY is mandatory (missing BYDAY raises 'WEEKLY schedules require BYDAY'), and after parse_byday the result must contain at least one day, otherwise this error fires.

Solutions

  1. Provide at least one valid day token in BYDAY (MO,TU,WE,TH,FR,SA,SU)
  2. Fix the UI/config writer to refuse saving WEEKLY with no selected days
  3. Check day-token spelling and separators against parse_byday's expected format

Example fix

// before
RRULE:FREQ=WEEKLY;BYDAY=;BYHOUR=9;BYMINUTE=0
// after
RRULE:FREQ=WEEKLY;BYDAY=MO,WE;BYHOUR=9;BYMINUTE=0
Defensive patterns

Strategy: validation

Validate before calling

const byday = (rule.match(/BYDAY=([^;]*)/)?.[1] ?? "").trim();
const days = byday.split(',').filter(d => ["MO","TU","WE","TH","FR","SA","SU"].includes(d.toUpperCase()));
if (days.length === 0) throw new Error("WEEKLY schedules require at least one valid BYDAY value");

Type guard

const isWeekday = (s: string): s is "MO"|"TU"|"WE"|"TH"|"FR"|"SA"|"SU" =>
  ["MO","TU","WE","TH","FR","SA","SU"].includes(s.toUpperCase());

Try / catch

try {
  parse_rrule(rule)?;
} catch e if e.to_string().contains("BYDAY cannot be empty") {
  eprintln!("{e}; select at least one weekday");
}

Prevention

When it happens

Trigger: Parsing 'RRULE:FREQ=WEEKLY;BYDAY=;BYHOUR=9;BYMINUTE=0' (empty value) or a BYDAY string whose tokens all fail to parse into days, leaving an empty vec.

Common situations: UI saving an empty weekday selection; config written with BYDAY= placeholder; unrecognized day tokens filtered out leaving nothing.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

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

View on GitHub (pinned to 73e0f67d83)