From 2ab0311b99278f70402c62ed481e9338908559ce Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Wed, 12 Aug 2026 03:08:55 -0400 Subject: [PATCH] fix: reject COUNT rules without DTSTART so limited automations cannot run forever (#27781) --- backend/open_webui/constants.py | 3 +++ backend/open_webui/utils/automations.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/backend/open_webui/constants.py b/backend/open_webui/constants.py index a1d1bc73ca..fd61fda228 100644 --- a/backend/open_webui/constants.py +++ b/backend/open_webui/constants.py @@ -118,6 +118,9 @@ class ERROR_MESSAGES(str, Enum): AUTOMATION_TOO_FREQUENT = lambda interval='': f'Schedule too frequent. Minimum interval is {interval} seconds.' AUTOMATION_INVALID_RRULE = lambda err='': f'Invalid RRULE: {err}' AUTOMATION_NO_FUTURE_RUNS = 'RRULE has no future occurrences' + AUTOMATION_COUNT_REQUIRES_DTSTART = ( + 'RRULE with COUNT requires an explicit DTSTART line to anchor the occurrence window' + ) FEATURE_DISABLED = lambda name='': f'{name} is disabled' INPUT_TOO_LONG = lambda size='': f'Input prompt exceeds maximum length of {size}' diff --git a/backend/open_webui/utils/automations.py b/backend/open_webui/utils/automations.py index 712ea45096..18da05f985 100644 --- a/backend/open_webui/utils/automations.py +++ b/backend/open_webui/utils/automations.py @@ -124,6 +124,9 @@ def validate_rrule(s: str, tz: str = None) -> None: clock so that near-future schedules are not incorrectly rejected on servers whose system clock is ahead (e.g. UTC vs US timezones). """ + upper = s.upper() + if 'COUNT=' in upper and 'DTSTART' not in upper: + raise ValueError(ERROR_MESSAGES.AUTOMATION_COUNT_REQUIRES_DTSTART) zi = _resolve_tz(tz) now = datetime.now(zi).replace(tzinfo=None) if zi else datetime.now() try: