Hmbown/CodeWhale · error · anyhow::Error

Unable to compute next HOURLY run for BYDAY filter

Error message

Unable to compute next HOURLY run for BYDAY filter

What it means

For an unanchored HOURLY schedule with a BYDAY weekday filter, the code advances the candidate by interval_hours up to 24*21 times (three weeks of hourly steps) looking for a weekday in the filter. If none of those candidates lands on an allowed weekday, it bails with this message. It is a bounded-search exhaustion, meaning the BYDAY filter is unreachable on the schedule's interval grid within three weeks.

Solutions

  1. Lower INTERVAL so the hourly grid lands on a BYDAY weekday within three weeks (INTERVAL < 168).
  2. Broaden BYDAY to include more weekdays.
  3. Use FREQ=WEEKLY with BYDAY/BYHOUR/BYMINUTE instead of a huge hourly interval plus day filter.

Example fix

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

Strategy: validation

Validate before calling

if schedule_is_hourly() && interval_hours >= 168 && !byday.is_empty() {
    return Err("HOURLY interval >= 1 week with BYDAY can never match");
}

Try / catch

match schedule.next_after_with_anchor(now, anchor) {
    Ok(next) => arm(next),
    Err(e) if e.to_string().contains("BYDAY filter") => surface_config_warning(),
    Err(e) => report(e),
}

Prevention

When it happens

Trigger: AutomationSchedule::Hourly with byday set and an interval_hours so large that interval hops skip over every allowed weekday within the 21-day search window (e.g. INTERVAL > 168 hours can hop week to week past all filtered days).

Common situations: Interval larger than a week combined with BYDAY; BYDAY list that never coincides with the candidate grid; typo in the stored RRULE giving a nonsensical interval.

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/d8533accfa5f9766. Report an issue: GitHub.

Appendix: source

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

                            .ok_or_else(|| anyhow::anyhow!("HOURLY schedule exceeded its range"))?;
                    }
                    bail!("Unable to compute next anchored HOURLY run");
                }

                let after_second = local_after.second();
                let after_nanosecond = local_after.nanosecond();
                let mut candidate = local_after + Duration::hours(i64::from(*interval_hours))
                    - Duration::seconds(i64::from(after_second))
                    - Duration::nanoseconds(i64::from(after_nanosecond));

                if let Some(days) = byday {
                    for _ in 0..(24 * 21) {
                        if days.contains(&candidate.weekday()) {
                            return Ok(candidate.with_timezone(&Utc));
                        }
                        candidate += Duration::hours(i64::from(*interval_hours));
                    }
                    bail!("Unable to compute next HOURLY run for BYDAY filter");
                }

                Ok(candidate.with_timezone(&Utc))
            }
            Self::Weekly {
                byday,
                byhour,
                byminute,
            } => {
                for day_offset in 0..15 {
                    let date = local_after.date_naive() + Duration::days(i64::from(day_offset));
                    if !byday.contains(&date.weekday()) {
                        continue;
                    }
                    let Some(candidate_naive) = date.and_hms_opt(*byhour, *byminute, 0) else {
                        continue;
                    };
                    if let Some(candidate) = resolve_local_datetime(timezone, candidate_naive)

View on GitHub (pinned to 73e0f67d83)