Fix DateTimeSensorAsync crash on templated target_time with start_from_trigger - #70469
Draft
burakcoleman wants to merge 1 commit into
Draft
Conversation
…m_trigger
DateTimeSensorAsync.__init__ computes start_trigger_args.trigger_kwargs["moment"]
by parsing target_time at Dag-parse time, before Jinja templating runs. Since
target_time is a documented template field, a templated value (e.g.
"{{ data_interval_end.tomorrow().replace(hour=1) }}") raises a raw
pendulum ParserError there, crashing parsing of the entire Dag file.
The parse can't be deferred to execute(): when start_from_trigger=True the
scheduler defers straight from TaskInstance.defer_task() using the
pre-computed start_trigger_args, so execute() never runs. That's the same
constraint TimeSensor hit in apache#69610, so this applies the same remedy: raise
a clear ValueError instead of letting the parser error propagate.
Static/ISO target_time values are unaffected and keep working as before.
closes: apache#70284
Related: apache#69610
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
Contributor
|
same than #70310 ? |
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.
DateTimeSensorAsync.__init__computesstart_trigger_args.trigger_kwargs["moment"]by callingtimezone.parse(self.target_time)at Dag-parse time, before Jinja templating has run.target_timeis a documented template field (e.g.
"{{ data_interval_end.tomorrow().replace(hour=1) }}"), so atemplated value raises a raw
pendulum.parsing.exceptions.ParserErrorthere, crashing parsing of theentire Dag file, not just the one task.
This can't be fixed by moving the parse into
execute(): whenstart_from_trigger=True, the schedulerdefers the task straight from
TaskInstance.defer_task()using the pre-computedself.task.start_trigger_args—
execute()never runs for this path. So the value genuinely has to be resolved in__init__, the sameconstraint
TimeSensorhit in #69610.Fix: catch the parse failure and raise a clear
ValueErrorexplaining thatstart_from_trigger=Truerequires a static
target_time, instead of letting the rawParserErrorpropagate and take down thewhole Dag file. Static/ISO
target_timevalues are unaffected and keep working exactly as before.Added tests covering both the static-time (still works) and templated-time (now raises a clear,
task-scoped error instead of crashing Dag parsing) cases.
closes: #70284
Related: #69610
Was generative AI tooling used to co-author this PR?