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 fa273d83075 Fix triggerer crash when trigger subclass does not call 
`super().__init__()` (#68636)
fa273d83075 is described below

commit fa273d83075f7c78843c67cb7ac550f12026ec19
Author: Vincent <[email protected]>
AuthorDate: Wed Jun 17 12:32:58 2026 -0400

    Fix triggerer crash when trigger subclass does not call 
`super().__init__()` (#68636)
---
 airflow-core/src/airflow/triggers/base.py             |  4 ++--
 airflow-core/tests/unit/triggers/test_base_trigger.py | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/airflow-core/src/airflow/triggers/base.py 
b/airflow-core/src/airflow/triggers/base.py
index 6f6061e3366..f587fd8de3f 100644
--- a/airflow-core/src/airflow/triggers/base.py
+++ b/airflow-core/src/airflow/triggers/base.py
@@ -101,8 +101,8 @@ class BaseTrigger(abc.ABC, Templater, LoggingMixin):
         return None
 
     @property
-    def task_instance(self) -> TaskInstance:
-        return self._task_instance
+    def task_instance(self) -> TaskInstance | None:
+        return getattr(self, "_task_instance", None)
 
     @task_instance.setter
     def task_instance(self, value: TaskInstance | None) -> None:
diff --git a/airflow-core/tests/unit/triggers/test_base_trigger.py 
b/airflow-core/tests/unit/triggers/test_base_trigger.py
index 5f32cb23bfe..429e5461529 100644
--- a/airflow-core/tests/unit/triggers/test_base_trigger.py
+++ b/airflow-core/tests/unit/triggers/test_base_trigger.py
@@ -140,6 +140,25 @@ def 
test_render_template_fields_empty_when_no_trigger_kwargs(create_task_instanc
     assert trigger.name == "Hello {{ name }}"
 
 
+class _TriggerWithoutSuperInit(BaseTrigger):
+    """A trigger that does not call super().__init__() — simulates third-party 
triggers."""
+
+    def __init__(self, queue_url: str):
+        self.queue_url = queue_url
+
+    def serialize(self):
+        return (f"{type(self).__module__}.{type(self).__qualname__}", 
{"queue_url": self.queue_url})
+
+    async def run(self):
+        yield TriggerEvent({"queue_url": self.queue_url})
+
+
+def test_task_instance_property_works_without_super_init():
+    """task_instance property must return None when subclass skips 
super().__init__()."""
+    trigger = 
_TriggerWithoutSuperInit(queue_url="https://sqs.example.com/queue";)
+    assert trigger.task_instance is None
+
+
 class _PlainEventTrigger(BaseEventTrigger):
     """A BaseEventTrigger that does not opt into shared streams."""
 

Reply via email to