Skip notifier templating with empty template_fields#64993
Open
DaveT1991 wants to merge 2 commits intoapache:v3-1-stablefrom
Open
Skip notifier templating with empty template_fields#64993DaveT1991 wants to merge 2 commits intoapache:v3-1-stablefrom
DaveT1991 wants to merge 2 commits intoapache:v3-1-stablefrom
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
Contributor
Author
|
Any updates about my code submission? |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes notifier callbacks failing under airflow dags test when the callback context contains a SerializedDAG by avoiding unnecessary Jinja environment setup when there are no template fields to render.
Changes:
- Return early from
BaseNotifier.render_template_fields()whentemplate_fieldsis empty. - Avoid calling
dag.get_template_env()when the context DAG object doesn’t support it (e.g.,SerializedDAG), falling back to a default environment. - Add regression tests covering notifier invocation and template rendering with a serialized DAG in the context.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
task-sdk/src/airflow/sdk/bases/notifier.py |
Skips templating work when template_fields is empty; adds safer template-env selection for non-DAG context objects. |
task-sdk/tests/task_sdk/bases/test_notifier.py |
Adds regression tests for notifier callback execution and template rendering when context["dag"] is a SerializedDAG. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Skip notifier templating setup when a notifier does not define any template fields.
When
airflow dags testexecutes DAG callbacks, the callback context can include aSerializedDAG.BaseNotifier.render_template_fields()currently always requests a template environment from the context DAG, even when there is nothing to render. For notifiers that rely on the default emptytemplate_fields, that raisesAttributeErrorbefore the callback can run.This change returns early when
template_fieldsis empty and adds a regression test that exercises a notifier callback with a serialized DAG context.Closes #64649
Testing
task-sdk/tests/task_sdk/bases/test_notifier.pygit diff --check