{"record":{"id":"f121fac3b91bb871","repo":"Hmbown/CodeWhale","slug":"hourly-schedule-exceeded-its-range","errorCode":null,"errorMessage":"HOURLY schedule exceeded its range","messagePattern":"HOURLY schedule exceeded its range","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":514,"sourceCode":"                    let anchor_naive = local_anchor_reference\n                        .date_naive()\n                        .and_hms_opt(hour, minute, 0)\n                        .ok_or_else(|| anyhow::anyhow!(\"Unable to construct HOURLY anchor\"))?;\n                    let interval_seconds = i64::from(*interval_hours) * 60 * 60;\n                    let elapsed_seconds = local_after\n                        .naive_local()\n                        .signed_duration_since(anchor_naive)\n                        .num_seconds();\n                    let mut steps = if elapsed_seconds < 0 {\n                        0\n                    } else {\n                        elapsed_seconds / interval_seconds + 1\n                    };\n\n                    for _ in 0..MAX_HOURLY_SEARCH_STEPS {\n                        let hours = i64::from(*interval_hours)\n                            .checked_mul(steps)\n                            .ok_or_else(|| anyhow::anyhow!(\"HOURLY schedule exceeded its range\"))?;\n                        let delta = Duration::try_hours(hours)\n                            .ok_or_else(|| anyhow::anyhow!(\"HOURLY schedule exceeded its range\"))?;\n                        let candidate_naive = anchor_naive\n                            .checked_add_signed(delta)\n                            .ok_or_else(|| anyhow::anyhow!(\"HOURLY schedule exceeded its range\"))?;\n\n                        if byday\n                            .as_ref()\n                            .is_none_or(|days| days.contains(&candidate_naive.weekday()))\n                            && let Some(candidate) =\n                                resolve_local_datetime(timezone, candidate_naive)\n                        {\n                            let candidate = candidate.with_timezone(&Utc);\n                            if candidate > after {\n                                return Ok(candidate);\n                            }\n                        }\n","sourceCodeStart":496,"sourceCodeEnd":532,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/automation_manager.rs#L496-L532","documentation":"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.","triggerScenarios":"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.","commonSituations":"Config typo like intervalHours: 999999999999, corrupted automation store, anchor set far in the past so steps is astronomically large.","solutions":["Correct interval_hours to a sane value (e.g. 1-8760)","Recreate the automation schedule with validated bounds","Reset the schedule anchor to a recent timestamp so step counts stay small"],"exampleFix":"// before\n{ \"freq\": \"HOURLY\", \"intervalHours\": 999999999999 }\n// after\n{ \"freq\": \"HOURLY\", \"intervalHours\": 6 }","handlingStrategy":"validation","validationCode":"const MAX_INTERVAL_HOURS: i64 = 24 * 365;\nfn valid_hourly_interval(h: i64) -> bool { (1..=MAX_INTERVAL_HOURS).contains(&h) }\n// check before saving\nif !valid_hourly_interval(interval_hours) { bail!(\"intervalHours out of range\"); }","typeGuard":"fn sane_interval(v: &serde_json::Value) -> bool {\n    v.as_i64().map(|h| (1..=8760).contains(&h)).unwrap_or(false)\n}","tryCatchPattern":"match next_run(&schedule, after) {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"exceeded its range\") => {\n        eprintln!(\"HOURLY interval too large or state corrupted; recreate the schedule\");\n        ScheduleError::RangeExceeded\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Bound interval_hours at creation and config load (fail loud on extremes)","Treat absurd intervals as corrupted state and require schedule recreation","Audit hand-edited automation stores for numeric corruption","Add an upper bound assertion near the arithmetic"],"tags":["automation","scheduling","overflow","datetime"],"backgroundTag":"value-out-of-range","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}