Fix schedule_rruleset date-based end_on failing with a UTC UNTIL error#171
Merged
Conversation
Any rule using a date-style end_on failed sanity parsing because the generated UNTIL value stayed naive while DTSTART picked up a TZID, which dateutil rejects. Convert the local end date to UTC before emitting it as UNTIL.
Wrap the webhook_key description line to stay within the 160-character pep8 limit enforced by ansible-test sanity and ruff.
blaipr
force-pushed
the
fix-rruleset-until-timezone
branch
from
July 10, 2026 20:46
3fd874c to
a6dd3d6
Compare
Contributor
Author
|
Rebased on current main. This also picks up a fix for the E501 line-too-long in |
cigamit
approved these changes
Jul 11, 2026
3 tasks
cigamit
pushed a commit
that referenced
this pull request
Jul 11, 2026
) The pytz-to-zoneinfo migration in #171 missed replacing the pytz call on the UNTIL timezone conversion line, leaving an undefined name that breaks both ruff (F821) and ansible-test sanity (pylint). Use ZoneInfo and datetime.timezone from the stdlib instead.
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.
Summary
In
plugins/lookup/schedule_rruleset.py, when a rule'send_onis a date (rather than a count), the plugin builds the rule with a naiveUNTILvalue while splicing;TZID=<zone>into the first rule'sDTSTART. The plugin then sanity-checks its own output withdateutil.rrule.rrulestr, and dateutil (>= 2.7, the plugin's stated minimum) rejects a naiveUNTILpaired with a timezone-awareDTSTART:This meant any rule with a date-style
end_onfailed, regardless of which timezone was used, including the default. Count-styleend_on(a positive integer string) was unaffected.I fixed this by interpreting the parsed
end_ondate in the rule's timezone and emittingUNTILas UTC in the RFC 5545 form dateutil expects (UNTIL=YYYYMMDDTHHMMSSZ), while leaving therrule.rrule()construction itself unchanged (it still uses the naive value internally, matching the naiveDTSTART, so no other behavior changes).The sibling
schedule_rrule.pyplugin emits the same naiveUNTILbut does not sanity-parse its own output, so it is unaffected by this bug and I left it untouched.Verification
Reproduced the bug on
origin/mainby loading the lookup plugin directly and callingrun():After the fix, the same calls:
dateutil.rrule.rrulestrparses the generated string without error.end_on: '2026-01-10'withtimezone='America/New_York'starting2026-01-01 00:00:00, the last occurrence is2026-01-10 00:00:00-05:00(10 occurrences total), matching midnight local time on the end date.timezone='UTC'too: last occurrence is2026-01-10 00:00:00+00:00.2026-03-01, end2026-03-20,America/New_York, with an EXRULE also using a dateend_on): the UTC offset correctly shifts from-05:00to-04:00across the March DST transition, and the exclusion rule still works.end_onand rules withoutend_onare unaffected.ruff check plugins/passes.