github-actions[bot] opened a new pull request, #77541:
URL: https://github.com/apache/airflow/pull/77541

   * Fix notifier crash when callback receives a dag without get_template_env
   
   When `airflow dags test` runs a failing Dag, `on_failure_callback` is
   invoked with `context["dag"]` set to a SerializedDAG, which has no
   `get_template_env` method. `Templater.get_template_env` therefore raised
   AttributeError and the notifier's `notify()` was never called, whether
   or not the notifier had template fields.
   
   Only ask the dag for its Jinja environment when it has
   `get_template_env`; otherwise fall back to the default
   SandboxedEnvironment that is already used when there is no dag. Real
   DAG objects are unaffected.
   
   Add regression tests for a templated notifier and for one without
   template fields, both given a dag object that lacks `get_template_env`.
   
   * Use a real SerializedDAG in notifier tests
   
   Build the dag passed to the notifier tests with create_scheduler_dag instead 
of a hand-made stand-in class, so the tests exercise the same SerializedDAG 
that 'airflow dags test' hands to callbacks. Both tests still fail with 
AttributeError without the hasattr guard in Templater.get_template_env.
   (cherry picked from commit 4dced2c8de922fdb044a1842eda5454e49ee54a9)
   
   Co-authored-by: sameer pandey 
<[email protected]>


-- 
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