potiuk commented on code in PR #40030:
URL: https://github.com/apache/airflow/pull/40030#discussion_r1625378926


##########
airflow/models/dag.py:
##########
@@ -800,10 +801,21 @@ def validate(self):
                 f"inconsistent schedule: timetable {self.timetable.summary!r} "
                 f"does not match schedule_interval {self.schedule_interval!r}",
             )
+        self.validate_executor_field()
         self.validate_schedule_and_params()
         self.timetable.validate()
         self.validate_setup_teardown()
 
+    def validate_executor_field(self):
+        for task in self.tasks:
+            if task.executor:
+                try:
+                    ExecutorLoader.lookup_executor_name_by_str(task.executor)
+                except AirflowException:

Review Comment:
   Agree with @uranusjr -> AirflowException is **NOT** supposed to be raised 
directly (even if it already is in a number of places). It's merely a parent 
exception for all the custom exceptions we implement.
   
   But in this case I think we do not really **need** to have a custom 
exception. Python has surprisingly small number of built-in exceptions, but 
they are versatile enough to be used in most cases unless you want to have 
really specific exception you want to handle; 
https://docs.python.org/3/library/exceptions.html
   
   Is there any reason we cannot use standard exception here (for example 
`ValueError`) or maybe one of already defined AirlfowException's ?



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