Hmbown/CodeWhale · error · anyhow::Error

Invalid RRULE segment

Error message

Invalid RRULE segment '{item}'

What it means

The automation manager parses RRULE strings (RFC 5545 recurrence rules) into key=value parts by splitting on ';' and then on '='. Any non-empty segment lacking an '=' — e.g. 'FREQ', 'DAILY;', or a stray token — is rejected with this error naming the offending segment.

Solutions

  1. Inspect the segment named in the message and ensure it has key=value form (e.g. INTERVAL=2).
  2. Start from a minimal valid rule: FREQ=<DAILY|WEEKLY|MONTHLY> and add parts one at a time.
  3. Trim whitespace and stray separators: "FREQ=DAILY;INTERVAL=1;BYDAY=MO".
  4. Validate the RRULE with a parser or `rrule` tooling before saving it into config.
  5. Check the automation's stored rrule in config/session files for corruption.

Example fix

// before: malformed segment
let rule = "FREQ=DAILY;INTERVAL";
// after: valid key=value segments
let rule = "FREQ=DAILY;INTERVAL=1";
Defensive patterns

Strategy: validation

Validate before calling

fn rrule_segments_valid(rrule: &str) -> bool {
    rrule.split(';')
        .map(str::trim)
        .filter(|s| !s.is_empty())
        .all(|s| s.split_once('=').map_or(false, |(k, v)| !k.trim().is_empty() && !v.trim().is_empty()))
}
// ensure rrule_segments_valid(&rule) before saving

Type guard

fn is_valid_rrule(s: &str) -> bool { rrule_segments_valid(s) && s.contains("FREQ=") }

Try / catch

match Automation::new(name, &rrule) {
    Err(e) if e.to_string().contains("Invalid RRULE segment") => {
        eprintln!("Fix the RRULE: {e}. Example: FREQ=DAILY;INTERVAL=1");
        prompt_user_for_rrule()
    }
    r => r?,
}

Prevention

When it happens

Trigger: Creating/updating an automation whose rrule string contains a ';'-separated segment without a key=value form, like "FREQ=DAILY;INTERVAL" or trailing garbage "FREQ=DAILY;;oops".

Common situations: Hand-typed cron/RRULE strings in config; copying RRULE fragments from calendar apps that include options the parser doesn't split; whitespace mangled so the '=' was lost; pasting a human-readable description instead of an RRULE.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

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

        byday: Vec<Weekday>,
        byhour: u32,
        byminute: u32,
    },
    Cron {
        expr: String,
    },
}

impl AutomationSchedule {
    pub fn parse_rrule(rrule: &str) -> Result<Self> {
        let mut parts: BTreeMap<String, String> = BTreeMap::new();
        for raw in rrule.split(';') {
            let item = raw.trim();
            if item.is_empty() {
                continue;
            }
            let Some((k, v)) = item.split_once('=') else {
                bail!("Invalid RRULE segment '{item}'");
            };
            parts.insert(k.trim().to_ascii_uppercase(), v.trim().to_string());
        }

        let freq = match parts
            .get("FREQ")
            .map(|value| value.trim().to_ascii_uppercase())
            .as_deref()
        {
            Some("ONCE") => return parse_once_schedule(&parts),
            Some("HOURLY") => AutomationFrequency::Hourly,
            Some("WEEKLY") => AutomationFrequency::Weekly,
            Some("CRON") => return parse_cron_schedule(&parts),
            Some(other) => {
                bail!("Unsupported RRULE FREQ '{other}'. Supported: ONCE, HOURLY, WEEKLY, and CRON")
            }
            None => bail!("RRULE must include FREQ"),
        };

View on GitHub (pinned to 73e0f67d83)