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


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -451,8 +452,27 @@ def materialize_asset(
             f"Dag with dag_id: '{dag_id}' does not allow asset materialization 
runs",
         )
 
+    resolved_body = body or MaterializeAssetBody()
+
+    resolved_dag_version = None
+    if resolved_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",
+            )
+        resolved_dag_version = DagVersion.get_latest_version(
+            dag.dag_id, bundle_version=resolved_body.bundle_version, 
load_serialized_dag=True, session=session
+        )
+        if resolved_dag_version is None:
+            raise HTTPException(
+                status.HTTP_404_NOT_FOUND,
+                f"DAG with dag_id: '{dag_id}' does not have a version for 
bundle_version '{resolved_body.bundle_version}'",
+            )
+        dag = resolved_dag_version.serialized_dag.dag
+
     try:
-        params = (body or MaterializeAssetBody()).validate_context(dag)
+        params = (resolved_body or 
MaterializeAssetBody()).validate_context(dag)

Review Comment:
   Done



##########
airflow-core/src/airflow/api_fastapi/core_api/datamodels/dag_run.py:
##########
@@ -197,6 +198,7 @@ def validate_context(self, dag: SerializedDAG) -> dict:
             "conf": self.conf,
             "note": self.note,
             "partition_key": self.partition_key,
+            "bundle_version": self.bundle_version,

Review Comment:
   Done



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