aashish254 opened a new pull request, #77295: URL: https://github.com/apache/airflow/pull/77295
## What changes are being proposed? Fixes #64649 When running `airflow dags test` with a notifier that has template_fields, the notifier's `render_template_fields` would fail with `AttributeError` because SerializedDAG objects lack `get_template_env()` and `render_template_as_native_obj` attributes that regular DAG objects have. ## Why are these changes needed? This fix ensures notifiers work correctly when running DAGs locally through tests, which is essential for: - Testing notifier implementations during development - Local DAG validation workflows - CI/CD pipelines that test DAGs before deployment ## Changes: - Modified `Templater.get_template_env()` to check for `get_template_env` attribute before calling it - Modified `Templater._should_render_native()` to use `getattr` with a default value - Added test case `test_render_with_serialized_dag` to verify notifier works with SerializedDAG-like objects ## Testing: - Added new test case that reproduces the issue and verifies the fix - All existing notifier tests pass (6/6) - The fix gracefully falls back to default template environment when DAG attributes are missing ## Related Issues: Closes #64649 --- **Note**: This contribution was created with AI assistance. -- 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]
