dabla opened a new issue, #53063:
URL: https://github.com/apache/airflow/issues/53063

   ### 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 
](https://github.com/apache/airflow/blob/main/airflow-core/docs/authoring-and-scheduling/deferring.rst)
 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](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/models/dagrun.py#L1929)
 method of the 
[DagRun](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/models/dagrun.py)
 class should render the templated fields of the task first before invoking the 
[expand_start_from_trigger](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/models/baseoperator.py#L415)
 method on the 
[task](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/models/baseoperator.py)
 (e.g. BaseOperator).
   
   Then the 
[expand_start_from_trigger](https://github.com/apache/airflow/blob/main/airflow-core/src/airflow/models/baseoperator.py#L415)
 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](https://github.com/apache/airflow/blob/main/providers/standard/src/airflow/providers/standard/sensors/date_time.py#L108))
 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?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to