Hmbown/CodeWhale · error

HOURLY schedule exceeded its range

Error message

HOURLY schedule exceeded its range

What it means

The HOURLY next-run search multiplies the configured interval_hours by the computed step count; if that multiplication overflows i64 the schedule cannot be advanced within representable time and the search aborts with this error.

Solutions

  1. Correct interval_hours to a sane value (e.g. 1-8760)
  2. Recreate the automation schedule with validated bounds
  3. Reset the schedule anchor to a recent timestamp so step counts stay small

Example fix

// before
{ "freq": "HOURLY", "intervalHours": 999999999999 }
// after
{ "freq": "HOURLY", "intervalHours": 6 }
Defensive patterns

Strategy: validation

Validate before calling

const MAX_INTERVAL_HOURS: i64 = 24 * 365;
fn valid_hourly_interval(h: i64) -> bool { (1..=MAX_INTERVAL_HOURS).contains(&h) }
// check before saving
if !valid_hourly_interval(interval_hours) { bail!("intervalHours out of range"); }

Type guard

fn sane_interval(v: &serde_json::Value) -> bool {
    v.as_i64().map(|h| (1..=8760).contains(&h)).unwrap_or(false)
}

Try / catch

match next_run(&schedule, after) {
    Ok(r) => r,
    Err(e) if e.to_string().contains("exceeded its range") => {
        eprintln!("HOURLY interval too large or state corrupted; recreate the schedule");
        ScheduleError::RangeExceeded
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A HOURLY schedule with an enormous interval_hours value (or a step count inflated by a far-future anchor), making interval_hours * steps exceed i64::MAX in checked_mul.

Common situations: Config typo like intervalHours: 999999999999, corrupted automation store, anchor set far in the past so steps is astronomically large.

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

Appendix: source

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

                    let anchor_naive = local_anchor_reference
                        .date_naive()
                        .and_hms_opt(hour, minute, 0)
                        .ok_or_else(|| anyhow::anyhow!("Unable to construct HOURLY anchor"))?;
                    let interval_seconds = i64::from(*interval_hours) * 60 * 60;
                    let elapsed_seconds = local_after
                        .naive_local()
                        .signed_duration_since(anchor_naive)
                        .num_seconds();
                    let mut steps = if elapsed_seconds < 0 {
                        0
                    } else {
                        elapsed_seconds / interval_seconds + 1
                    };

                    for _ in 0..MAX_HOURLY_SEARCH_STEPS {
                        let hours = i64::from(*interval_hours)
                            .checked_mul(steps)
                            .ok_or_else(|| anyhow::anyhow!("HOURLY schedule exceeded its range"))?;
                        let delta = Duration::try_hours(hours)
                            .ok_or_else(|| anyhow::anyhow!("HOURLY schedule exceeded its range"))?;
                        let candidate_naive = anchor_naive
                            .checked_add_signed(delta)
                            .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);
                            }
                        }

View on GitHub (pinned to 73e0f67d83)