This is an automated email from the ASF dual-hosted git repository.
vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new af62d7735fa Stop the test listener erroring on Task SDK task instances
(#77393)
af62d7735fa is described below
commit af62d7735fa1b28aeacdd00469e901c43119f82d
Author: Vincent <[email protected]>
AuthorDate: Mon Nov 23 10:24:05 2026 -0500
Stop the test listener erroring on Task SDK task instances (#77393)
AirflowTestPlugin registers ClassBasedListener in every test run, including
AWS system tests run through dag.test. There the Task SDK hands the listener
a RuntimeTaskInstance, which has no note, so every task logged an
"error calling listener" AttributeError traceback. The task runner swallows
it, so tasks still pass, but the tracebacks make real system test failures
harder to find.
---
airflow-core/tests/unit/listeners/class_listener.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/airflow-core/tests/unit/listeners/class_listener.py
b/airflow-core/tests/unit/listeners/class_listener.py
index 75d7d73d4bd..eae37ea1601 100644
--- a/airflow-core/tests/unit/listeners/class_listener.py
+++ b/airflow-core/tests/unit/listeners/class_listener.py
@@ -41,25 +41,27 @@ class ClassBasedListener:
self.stopped_component = component
self.state.append(DagRunState.SUCCESS)
+ # ``AirflowTestPlugin`` registers this listener in every test run,
including tasks run by the
+ # Task SDK, whose ``RuntimeTaskInstance`` has no ``note``.
@hookimpl
def on_task_instance_running(self, previous_state, task_instance):
self.state.append(TaskInstanceState.RUNNING)
- self.ti_note_at_listener = task_instance.note
+ self.ti_note_at_listener = getattr(task_instance, "note", None)
@hookimpl
def on_task_instance_success(self, previous_state, task_instance):
self.state.append(TaskInstanceState.SUCCESS)
- self.ti_note_at_listener = task_instance.note
+ self.ti_note_at_listener = getattr(task_instance, "note", None)
@hookimpl
def on_task_instance_failed(self, previous_state, task_instance, error:
None | str | BaseException):
self.state.append(TaskInstanceState.FAILED)
- self.ti_note_at_listener = task_instance.note
+ self.ti_note_at_listener = getattr(task_instance, "note", None)
@hookimpl
def on_task_instance_skipped(self, previous_state, task_instance):
self.state.append(TaskInstanceState.SKIPPED)
- self.ti_note_at_listener = task_instance.note
+ self.ti_note_at_listener = getattr(task_instance, "note", None)
@hookimpl
def on_dag_run_running(self, dag_run, msg: str):