Reject inverted date windows in airflow partitions clear#69454
Merged
Conversation
jason810496
approved these changes
Jul 7, 2026
jason810496
left a comment
Member
There was a problem hiding this comment.
Nice to have hardening before merging.
The CLI silently reported no matching DagRuns for an inverted --start-date/--end-date window (or --date 'a~b' range) instead of rejecting it, unlike the equivalent `dags clear` and REST validations. Added the same ordering check with a matching error message.
…error When the inverted date window comes from --date a~b, the error previously said "--start-date must be on or before --end-date", naming flags the user never typed. It now names --date and echoes the two values the user supplied.
…alized comparison used downstream The guard compared --start-date/--end-date as absolute instants, but the downstream partition_date query re-interprets them through the Dag's timetable timezone, which for cron-based timetables discards the user-supplied UTC offset and re-localizes the wall-clock reading. A window that was wall-clock valid could be wrongly rejected, and one that was wall-clock inverted could be wrongly accepted. The guard now localizes both bounds the same way the query will before comparing.
91a0480 to
9ec800d
Compare
Contributor
|
Hi maintainer, this PR was merged without a milestone set.
|
Contributor
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Jul 7, 2026
…pache#69454) (cherry picked from commit 1ff2114) Co-authored-by: Wei Lee <weilee.rx@gmail.com>
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
Jul 7, 2026
…pache#69454) (cherry picked from commit 1ff2114) Co-authored-by: Wei Lee <weilee.rx@gmail.com>
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.
Why
airflow partitions clearsilently reported no matching Dag runs when given an inverted date window — a--start-datelater than--end-date, or a--date 'a~b'range whereais afterb. The command treated it as a valid-but-empty window instead of flagging the mistake, so a user who transposed the two dates got a misleading "nothing matched" result rather than an error. This is inconsistent withdags clear --partition-date-start/--partition-date-endand the RESTpartition_date_start/partition_date_endfields, which already reject invertedwindows with the equivalent message.
What
partition_command.clear: when both bounds are present andstart_date > end_date, raiseSystemExitwith--start-date must be on or before --end-date.--start-date/--end-dateflags and the--date 'a~b'range shorthand — by normalizing the parsed range into the samehas_start/has_endbounds before validating.Was generative AI tooling used to co-author this PR?
Generated-by: [Tool Name] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.