Skip to content

StartFromTrigger doesn't work with templated fields #53063

@dabla

Description

@dabla

Apache Airflow version

3.0.2

If "Other Airflow 2 version" selected, which one?

2.10 and higher

What happened?

When using the new start_from_trigger feature introduced in Airflow 2.10 which allows you to run an operator directly within the triggerer without the need to pass via the worker first (which is faster as the scheduler only has to handle the task once instead of twice), it doesn't work when your operator has templated fields.

This is because the start_trigger_args have to be defined within the class or the constructor, but at that time the possible trigger_kwargs could consist of templated fields, which at that time, aren't rendered yet.

What you think should happen instead?

To fix this issue, the schedule_tis method of the DagRun class should render the templated fields of the task first before invoking the expand_start_from_trigger method on the task (e.g. BaseOperator).

Then the expand_start_from_trigger method should be modified to iterate over the templated fields and re-assign those to the trigger_kwargs so that when instantiating the triggerer, it will have the rendered templated fields.

How to reproduce

Implement the start_from_trigger feature in an operator or sensor which has templated fields. As there only exist one sensor (e.g. DateTimeSensorAsync) using this feature in Airflow, I don't think anyone encountered this issue yet.

Operating System

Rocky Linux

Versions of Apache Airflow Providers

No response

Deployment

Other 3rd-party Helm chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions