o-nikolas commented on code in PR #57706:
URL: https://github.com/apache/airflow/pull/57706#discussion_r2487920520


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2703,9 +2703,18 @@ def _try_to_load_executor(self, executor_name: str | 
None) -> BaseExecutor | Non
             return self.job.executor
 
         for e in self.job.executors:
-            if e.name.alias == executor_name or e.name.module_path == 
executor_name:
+            if e.name and (e.name.alias == executor_name or e.name.module_path 
== executor_name):
                 return e
 
+        # Check if executor_name matches the default executor (first in the 
list)
+        # This handles the case where ti.executor is populated with the 
default executor's name
+        # but that executor isn't in the job.executors list (e.g., in unit 
tests)
+        default_executor = self.job.executor
+        if default_executor.name and (
+            default_executor.name.alias == executor_name or 
default_executor.name.module_path == executor_name
+        ):
+            return default_executor
+

Review Comment:
   Is this 100% intended to only be run as test code? Why are we doing this 
here? We should use proper mocking in our tests to get the effects we need, not 
update source code



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