rawwar commented on code in PR #49164:
URL: https://github.com/apache/airflow/pull/49164#discussion_r2040805924


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -318,8 +325,19 @@ def materialize_asset(
             f"More than one DAG materializes asset with ID: {asset_id}",
         )
 
-    dag: DAG | None
-    if not (dag := request.app.state.dag_bag.get_dag(dag_id)):
+    try:
+        dag: DAG = request.app.state.dag_bag.get_dag(dag_id)
+    except (ImportError, SyntaxError):
+        raise HTTPException(
+            status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
+            detail=f"Failed to parse DAG '{dag_id}'. Check DAG file syntax or 
dependencies.",
+        )

Review Comment:
   `DagBag.get_dag` will not raise Import error or Syntax Error. Based on 
what's mentioned in the linked issue, we should be handling deserialization 
errors. 



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