Skip to content

fix: skip schedules with invalid cron_offset instead of crashing the scheduler - #669

Open
juanmicl wants to merge 2 commits into
taskiq-python:masterfrom
juanmicl:fix/scheduler-invalid-cron-offset-crash
Open

fix: skip schedules with invalid cron_offset instead of crashing the scheduler#669
juanmicl wants to merge 2 commits into
taskiq-python:masterfrom
juanmicl:fix/scheduler-invalid-cron-offset-crash

Conversation

@juanmicl

@juanmicl juanmicl commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Closes: #668

is_cron_task_now called ZoneInfo(offset) outside the try/except
that converts errors into CronValueError, and the scheduler loop only
catches CronValueError. One schedule with a non-IANA cron_offset
string (e.g. the natural spelling "UTC+3") raised
ZoneInfoNotFoundError out of SchedulerLoop.run and killed the whole
scheduler process.

With this change a bad offset goes through the same path as an invalid
cron expression: CronValueError is raised, the loop logs the existing
Cannot parse cron warning and skips that schedule.

Two regression tests cover invalid offset strings: the natural spelling
"UTC+3" and a typo'd timezone name ("Europa/Madrid"). Both fail on
master with ZoneInfoNotFoundError and pass with this change.

Complements #625 (which fixes duration-string offsets at
model-validation time but leaves the runtime guard unhandled).

Validation: full suite passes (pytest -q, 324 tests), black, ruff
and mypy clean.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.65%. Comparing base (c4b8666) to head (5fa2c05).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #669      +/-   ##
==========================================
+ Coverage   82.63%   82.65%   +0.01%     
==========================================
  Files          69       69              
  Lines        2730     2733       +3     
==========================================
+ Hits         2256     2259       +3     
  Misses        474      474              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A schedule with an invalid cron_offset string crashes the whole scheduler

1 participant