You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2024/10/28 00:58:41 UTC

(airflow) branch main updated: Optimize retrieval of `conn_id` and `dag_id` fields in `AirflowSecurityManagerV2` (#43420)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 5b7977a1494 Optimize retrieval of `conn_id` and `dag_id` fields in `AirflowSecurityManagerV2` (#43420)
5b7977a1494 is described below

commit 5b7977a149492168688e6f013a7dcd4fe3561a49
Author: Kaxil Naik <ka...@apache.org>
AuthorDate: Mon Oct 28 00:58:33 2024 +0000

    Optimize retrieval of `conn_id` and `dag_id` fields in `AirflowSecurityManagerV2` (#43420)
---
 airflow/www/security_manager.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/airflow/www/security_manager.py b/airflow/www/security_manager.py
index cd2f9563fe2..bad5a6b28bf 100644
--- a/airflow/www/security_manager.py
+++ b/airflow/www/security_manager.py
@@ -183,18 +183,18 @@ class AirflowSecurityManagerV2(LoggingMixin):
         def get_connection_id(resource_pk):
             if not resource_pk:
                 return None
-            connection = session.scalar(select(Connection).where(Connection.id == resource_pk).limit(1))
-            if not connection:
+            conn_id = session.scalar(select(Connection.conn_id).where(Connection.id == resource_pk).limit(1))
+            if not conn_id:
                 raise AirflowException("Connection not found")
-            return connection.conn_id
+            return conn_id
 
         def get_dag_id_from_dagrun_id(resource_pk):
             if not resource_pk:
                 return None
-            dagrun = session.scalar(select(DagRun).where(DagRun.id == resource_pk).limit(1))
-            if not dagrun:
+            dag_id = session.scalar(select(DagRun.dag_id).where(DagRun.id == resource_pk).limit(1))
+            if not dag_id:
                 raise AirflowException("DagRun not found")
-            return dagrun.dag_id
+            return dag_id
 
         def get_dag_id_from_task_instance(resource_pk):
             if not resource_pk: