fix(calendar): localize cron start_time to timetable timezone before computing planned runs - #71248
Open
waterWang wants to merge 1 commit into
Open
fix(calendar): localize cron start_time to timetable timezone before computing planned runs#71248waterWang wants to merge 1 commit into
waterWang wants to merge 1 commit into
Conversation
…computing planned runs
waterWang
requested review from
bugraoz93,
choo121600,
ephraimbuddy,
henry3260,
jason810496,
pierrejeambrun,
rawwar and
shubhamraj-git
as code owners
August 6, 2026 17:00
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.
Closes #71234
Problem
Calendar view's planned/future runs for cron-based timetables are computed
in UTC wall-clock instead of the DAG's configured timezone. When a DAG
uses a non-UTC
default_timezone(e.g.Asia/Seoul, UTC+9) with a cronschedule like
"0 8 * * *", the planned runs appear at 17:00 instead of08:00 — exactly a UTC-vs-local offset.
The root cause is in
CalendarService._calculate_cron_planned_runs():croniterreceiveslast_data_interval.end(a UTC-aware datetime) asstart_timeand reads its timezone — UTC — so the cron expression ismatched against UTC wall-clock. The real scheduler (
CronMixin._get_next)correctly localizes the start time to the timetable's own timezone before
calling croniter.
Fix
Add imports for
convert_to_utc,make_aware,make_naivefromairflow._shared.timezones.timezone(same utilities used byCronMixin._get_next).In
_calculate_cron_planned_runs:_timezonefrom theCronMixincast.start_timeto that timezone viamake_naive()beforeconstructing
croniter.convert_to_utc(make_aware(...)).This matches the exact pattern used by
CronMixin._get_next()inairflow/timetables/_cron.py.Testing
All 19 existing calendar tests continue to pass. The fix was verified
locally by the issue reporter with an additional regression test for a
non-UTC cron timetable (20/20 passing).
Related
airflow dags clearclearing the wrong day for non-UTC partitioned timetables #67717 (same pattern, fixed inairflow dags clear)next_dagrun_info_v2path for non-cron timetables)