uranusjr commented on code in PR #40084:
URL: https://github.com/apache/airflow/pull/40084#discussion_r1682365659


##########
airflow/dag_processing/processor.py:
##########
@@ -796,8 +818,16 @@ def _execute_task_callbacks(self, dagbag: DagBag | None, 
request: TaskCallbackRe
         if task:
             ti.refresh_from_task(task)
 
-        ti.handle_failure(error=request.msg, test_mode=self.UNIT_TEST_MODE, 
session=session)
-        self.log.info("Executed failure callback for %s in state %s", ti, 
ti.state)
+        if callback_type is TaskInstanceState.SUCCESS:
+            context = ti.get_template_context(session=session)
+            if not ti.task:
+                return

Review Comment:
   Is this for type-checking? `get_template_context` already makes sure there 
is a task, so this check never returns. If this is only to convince Mypy, we 
can use either
   
   ```python
   context["task"].on_success_callback
   ```
   
   or
   
   ```python
   if TYPE_CHECKING:
       assert ti.task
   callbacks = ti.task.on_success_callback
   ```
   
   instead.



-- 
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]

Reply via email to