diff --git a/task-sdk/src/airflow/sdk/execution_time/supervisor.py b/task-sdk/src/airflow/sdk/execution_time/supervisor.py index 0fab0b87f2a3d..ddf78e4098270 100644 --- a/task-sdk/src/airflow/sdk/execution_time/supervisor.py +++ b/task-sdk/src/airflow/sdk/execution_time/supervisor.py @@ -1125,7 +1125,7 @@ def _send_heartbeat_if_needed(self): except Exception as e: self._handle_heartbeat_failures(e) - def _handle_heartbeat_failures(self, exc: Exception | None): + def _handle_heartbeat_failures(self, exc: Exception): """Increment the failed heartbeats counter and kill the process if too many failures.""" self.failed_heartbeats += 1 log.warning( @@ -1133,7 +1133,7 @@ def _handle_heartbeat_failures(self, exc: Exception | None): failed_heartbeats=self.failed_heartbeats, ti_id=self.id, max_retries=MAX_FAILED_HEARTBEATS, - exception=exc, + exc_info=exc, ) # If we've failed to heartbeat too many times, kill the process if self.failed_heartbeats >= MAX_FAILED_HEARTBEATS: diff --git a/task-sdk/tests/task_sdk/execution_time/test_supervisor.py b/task-sdk/tests/task_sdk/execution_time/test_supervisor.py index 6ee7ab980d2ff..7c9828a29fd79 100644 --- a/task-sdk/tests/task_sdk/execution_time/test_supervisor.py +++ b/task-sdk/tests/task_sdk/execution_time/test_supervisor.py @@ -857,7 +857,7 @@ def test_heartbeat_failures_handling(self, monkeypatch, mocker, captured_logs, t "level": "warning", "logger": "supervisor", "timestamp": mocker.ANY, - "exception": mocker.ANY, + "exc_info": mocker.ANY, "loc": mocker.ANY, }