From a3a76cc0b17b9fd0aa5201c615d0dceb41832627 Mon Sep 17 00:00:00 2001 From: JunghwanNA <70629228+shaun0927@users.noreply.github.com> Date: Fri, 17 Apr 2026 16:48:44 +0900 Subject: [PATCH] fix(scheduler): reject zero/negative interval in every_N parsing After PR #76 wrapped _parse_cooldown in try/except, parse('every_0h') still returns timedelta(0). The cooldown check at check() then always fires the task on the next 120s scheduler cycle, in effect running a side-effectful task continuously instead of every N hours. Add a positive-interval validation inside the existing try block so the malformed case falls through to the existing 'fallback to 20h cooldown' warning path, the same way 'every_h' or 'every_xyz' do. Builds on the guard introduced by PR #76. --- reflect/scheduler.py | 1 + 1 file changed, 1 insertion(+) diff --git a/reflect/scheduler.py b/reflect/scheduler.py index 28d701ef..37459923 100644 --- a/reflect/scheduler.py +++ b/reflect/scheduler.py @@ -39,6 +39,7 @@ def _parse_cooldown(repeat): try: parts = repeat.split('_') n = int(parts[1].rstrip('hdm')) + if n <= 0: raise ValueError(f'positive interval required, got {n}') u = parts[1][-1] if u == 'h': return timedelta(hours=n) if u == 'm': return timedelta(minutes=n)