psg2 commented on a change in pull request #16842:
URL: https://github.com/apache/airflow/pull/16842#discussion_r664984122



##########
File path: airflow/api_connexion/endpoints/dag_endpoint.py
##########
@@ -34,14 +34,14 @@
 
 
 @security.requires_access([(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_DAG)])
-@provide_session
-def get_dag(dag_id, session):
+def get_dag(dag_id):
     """Get basic information about a DAG."""
-    dag = session.query(DagModel).filter(DagModel.dag_id == 
dag_id).one_or_none()
-
+    try:
+        dag: DAG = current_app.dag_bag.get_dag(dag_id)
+    except SerializedDagNotFound:
+        raise NotFound("DAG not found", detail=f"The DAG with dag_id: {dag_id} 
was not found")
     if dag is None:
         raise NotFound("DAG not found", detail=f"The DAG with dag_id: {dag_id} 
was not found")
-
     return dag_schema.dump(dag)

Review comment:
       If I'm not mistaken the `get_dag` method indeed returns a DAG object, so 
instead of updating the typing, should I query it from the database after 
validating its existence on the DagBag?




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