pierrejeambrun commented on code in PR #61550:
URL: https://github.com/apache/airflow/pull/61550#discussion_r2833400892


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dag_run.py:
##########
@@ -466,6 +466,22 @@ def trigger_dag_run(
         dag = get_latest_version_of_dag(dag_bag, dag_id, session)
         params = body.validate_context(dag)
 
+        if body.bundle_version is not None:
+            if dag.disable_bundle_versioning:
+                raise HTTPException(
+                    status.HTTP_400_BAD_REQUEST,
+                    f"DAG with dag_id: '{dag_id}' does not support bundle 
versioning",
+                )
+
+            dag_version = DagVersion.get_latest_version(
+                dag_id, bundle_version=body.bundle_version, session=session
+            )
+            if not dag_version:
+                raise HTTPException(
+                    status.HTTP_404_NOT_FOUND,
+                    f"DAG with dag_id: '{dag_id}' does not have a version for 
bundle_version '{body.bundle_version}'",
+                )

Review Comment:
   You can remove the check here. 
   
   Instead `create_dagrun` will raise a:
   ```python
       if not dag_version:
           raise AirflowException(f"Cannot create DagRun for DAG {dag.dag_id} 
because the dag is not serialized")
   ```
   
   To not have the route error 500 internal, you need to catch the 
AirflowException here and raise a 400 or 404 from it. (here in the dag_run.py)



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