Do not crash when an unsatisfiable day-of-month is OR-combined with day-of-week#243
Open
semx wants to merge 1 commit into
Open
Do not crash when an unsatisfiable day-of-month is OR-combined with day-of-week#243semx wants to merge 1 commit into
semx wants to merge 1 commit into
Conversation
semx
force-pushed
the
fix-dom-dow-unsatisfiable
branch
from
July 15, 2026 09:33
252490a to
28ec077
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the day-of-month and day-of-week fields are both restricted (neither is
*) with the default OR semantics (day_or=True, matching Vixie/POSIX cron),cronitercomputes the day-of-month next time and the day-of-week next time and returns the earlier of the two.If the day-of-month side is unsatisfiable — e.g. day
31restricted to months that never have a 31st — the internal_calcraisesCroniterBadDateError, which propagates and abortsget_next/get_preventirely, discarding the perfectly valid day-of-week result.Under OR semantics an impossible side should contribute nothing, not kill the schedule.
is_valid()already accepts these expressions, so they pass validation and then crash at resolution time.man 5 crontab(Vixie): "if both fields are restricted (i.e., aren't*), the command will be run when either field matches the current time." Day 31 never matches in February, so the schedule should fire on Mondays.Other affected expressions:
0 0 30 2 1-5,0 0 31 4 0,0 0 31 2,4,6,9,11 1. Any scheduler built on croniter (Airflow, Dagster, Celery-beat, APScheduler, …) errors at schedule-resolution time for these, and the intended weekday schedule never runs.Fix
Guard both branches of the DOM/DOW union: if a side raises
CroniterBadDateError, treat it as "no match" and use the other side; raise only if both are unsatisfiable. Satisfiable cases are unchanged.Tests
Added
test_dom_dow_both_restricted_with_unsatisfiable_domcoveringget_next,get_prev, and that a satisfiable DOM side still behaves as before. Full suite: 221 passed.