Hmbown/CodeWhale · error · anyhow::Error

BYMINUTE must be between 0 and 59

Error message

BYMINUTE must be between 0 and 59

What it means

Range guard in the RRULE parser: after BYMINUTE parses as an integer, its value is checked against the 0..=59 minute domain before a WEEKLY/DAILY schedule is accepted. It fires when the BYMINUTE token is numeric but out of range (e.g. BYMINUTE=75). Non-numeric or missing values produce different errors.

Solutions

  1. Use BYMINUTE between 0 and 59 (top of the hour is 0)
  2. Validate the minute field before persisting the schedule
  3. Omit BYMINUTE to use the default

Example fix

// before
RRULE:FREQ=HOURLY;BYMINUTE=60
// after
RRULE:FREQ=HOURLY;BYMINUTE=0
Defensive patterns

Strategy: validation

Validate before calling

const m = rule.match(/BYMINUTE=(\d+)/);
if (m && Number(m[1]) > 59) throw new Error("BYMINUTE must be between 0 and 59");

Type guard

function isValidMinute(m: number): boolean { return Number.isInteger(m) && m >= 0 && m <= 59; }

Try / catch

try {
  parse_rrule(rule)?;
} catch e if e.to_string().contains("BYMINUTE must be between 0 and 59") {
  eprintln!("{e}; use 0-59");
}

Prevention

When it happens

Trigger: Parsing 'RRULE:FREQ=HOURLY;BYMINUTE=60' or 'BYMINUTE=90'.

Common situations: Users entering 60 for 'top of the hour'; seconds confused for minutes; arithmetic producing values > 59.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

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

                let byday = parts
                    .get("BYDAY")
                    .map(|value| parse_byday(&value.to_ascii_uppercase()))
                    .transpose()?;
                let anchor_hour = parts
                    .get("BYHOUR")
                    .map(|value| value.parse::<u32>())
                    .transpose()
                    .context("Failed to parse BYHOUR")?;
                let anchor_minute = parts
                    .get("BYMINUTE")
                    .map(|value| value.parse::<u32>())
                    .transpose()
                    .context("Failed to parse BYMINUTE")?;
                if anchor_hour.is_some_and(|hour| hour > 23) {
                    bail!("BYHOUR must be between 0 and 23");
                }
                if anchor_minute.is_some_and(|minute| minute > 59) {
                    bail!("BYMINUTE must be between 0 and 59");
                }
                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")

View on GitHub (pinned to 73e0f67d83)