Hmbown/CodeWhale · error · anyhow::Error

Unable to compute next anchored HOURLY run

Error message

Unable to compute next anchored HOURLY run

What it means

Thrown when the anchored-HOURLY search exhausts MAX_HOURLY_SEARCH_STEPS without finding a candidate on the interval grid that passes the BYDAY filter and resolves to a real local time. The schedule advances `interval_hours` from a wall-clock anchor each step; if no eligible step lands within the bounded search window, the algorithm gives up instead of looping forever.

Solutions

  1. Reduce INTERVAL (interval_hours) or widen/fix the BYDAY list so a matching weekday occurs within the search window.
  2. Remove the anchor (anchor_hour/anchor_minute) if a plain relative hourly cadence is intended.
  3. Inspect the stored RRULE for a corrupt or extreme interval value and correct it.

Example fix

// before
"FREQ=HOURLY;INTERVAL=100000;BYDAY=MO"
// after
"FREQ=HOURLY;INTERVAL=2;BYDAY=MO,TU,WE,TH,FR"
Defensive patterns

Strategy: validation

Validate before calling

if interval_hours > 24 * 7 {
    return Err("HOURLY interval too large; use WEEKLY instead");
}
if !byday.is_empty() && interval_hours > 168 {
    return Err("BYDAY unreachable at this interval");
}

Try / catch

match schedule.next_after_with_anchor(now, anchor) {
    Ok(next) => arm(next),
    Err(e) if e.to_string().contains("anchored HOURLY") => flag_schedule_unreachable(),
    Err(e) => report(e),
}

Prevention

When it happens

Trigger: An HOURLY schedule with anchor_hour/anchor_minute set whose BYDAY filter combined with the interval never yields a matching weekday within the bounded step count, or whose interval math overflows the search window (e.g. absurdly large interval_hours).

Common situations: Config with a very large FREQ=HOURLY;INTERVAL combined with BYDAY so the next matching day falls outside the search bound; a mistyped BYDAY list that matches no upcoming weekday within the window; corrupted stored schedule where interval_hours is huge.

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

Appendix: source

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

                            .ok_or_else(|| anyhow::anyhow!("HOURLY schedule exceeded its range"))?;

                        if byday
                            .as_ref()
                            .is_none_or(|days| days.contains(&candidate_naive.weekday()))
                            && let Some(candidate) =
                                resolve_local_datetime(timezone, candidate_naive)
                        {
                            let candidate = candidate.with_timezone(&Utc);
                            if candidate > after {
                                return Ok(candidate);
                            }
                        }

                        steps = steps
                            .checked_add(1)
                            .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");
                }

View on GitHub (pinned to 73e0f67d83)