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


##########
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:
   This check is already done inside the `create_dagrun`. We don't need to make 
the db query twice. 
   
   We can raise inside the `create_dagrun`, a generic error (value error for 
instance), catch it here and convert that to an HTTpException 404.



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