prasad-anandappa opened a new pull request, #76404: URL: https://github.com/apache/airflow/pull/76404
Dag callbacks executed by `airflow dags test` receive a serialized Dag in the callback context. When the callback is a notifier, `BaseNotifier.render_template_fields()` asks the Dag for its Jinja environment via `Templater.get_template_env()`, which called `dag.get_template_env()` unconditionally — but `SerializedDAG` has no such method, so the callback crashed with `AttributeError` and `notify()` never ran. This makes `Templater.get_template_env()` use the Dag's environment only when the Dag actually provides `get_template_env()`, and otherwise fall back to the default sandboxed environment already used when there is no Dag. Known limitation of the fallback: the sandboxed environment has no Dag-level `user_defined_macros`/filters. Regression tests cover both notifier shapes with a serialized-Dag stand-in — a notifier with `template_fields` and one without any. Both crashed with `AttributeError` before this change and pass with it. The full `test_notifier.py` file passes (7 tests); the wider task-sdk bases and templater tests also pass apart from 3 failures that occur identically on unmodified upstream code in this environment (unrelated decorator/hook tests). Related to #74973, which has seen no activity since Oct 30 and no maintainer review or workflow approval; happy to close this PR if that one moves forward again. closes: #64649 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Muse Spark Generated-by: Muse Spark following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) --- Drafted-by: Muse Spark (no human review before posting) -- 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]
