uranusjr commented on code in PR #23510:
URL: https://github.com/apache/airflow/pull/23510#discussion_r884199036


##########
airflow/security/permissions.py:
##########
@@ -66,14 +66,16 @@
 DAG_ACTIONS = {ACTION_CAN_READ, ACTION_CAN_EDIT, ACTION_CAN_DELETE}
 
 
-def resource_name_for_dag(dag_id):
+def resource_name_for_dag(dag_id, is_subdag=False):
     """Returns the resource name for a DAG id."""
     if dag_id == RESOURCE_DAG:
         return dag_id
 
     if dag_id.startswith(RESOURCE_DAG_PREFIX):
         return dag_id
 
-    # To account for SubDags
-    root_dag_id = dag_id.split(".")[0]
-    return f"{RESOURCE_DAG_PREFIX}{root_dag_id}"
+    if is_subdag:
+        # To account for SubDags
+        root_dag_id = dag_id.split(".", 1)[0]

Review Comment:
   `parent_dag` is more expensive since it needs to load the entire DagModel 
object. Since this permission check is called a lot, I would prefer the check 
to be as light as possible. It would be better to use `root_dag_id` instead 
(which `parent_dag` is based on anyway!)



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to