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


##########
airflow/models/dag.py:
##########
@@ -2586,14 +2586,23 @@ def create_dagrun(
             else:
                 data_interval = 
self.infer_automated_data_interval(logical_date)
 
+        if run_type is not None and not isinstance(run_type, DagRunType):
+            raise ValueError(f"`run_type` should be a DagRunType, not 
{type(run_type)}")
+
         if run_id:  # Infer run_type from run_id if needed.
             if not isinstance(run_id, str):
                 raise ValueError(f"`run_id` should be a str, not 
{type(run_id)}")
-            if not run_type:
-                run_type = DagRunType.from_run_id(run_id)
+            inferred_run_type = DagRunType.from_run_id(run_id)
+            if run_type is None:
+                # No explicit type given, use the inferred type.
+                run_type = inferred_run_type
+            elif run_type == DagRunType.MANUAL and inferred_run_type != 
DagRunType.MANUAL:

Review Comment:
   I considered this as well. Airflow always only generate the run ID of an 
automated run with an appropriate format, so this is probably unless someone is 
delibrately manipulating Airflow to do otherwise (e.g. calling `create_dagrun` 
directly). I opted for the current approach to keep the impact as little as 
possible, but the alternative is also fine for me.



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