Skip to content

Commit

Permalink
Fix implicit cartessian product in AirflowSecurityManagerV2 (#38913)
Browse files Browse the repository at this point in the history
Co-authored-by: Tzu-ping Chung <[email protected]>
(cherry picked from commit e16dc0f)
  • Loading branch information
Taragolis authored and jedcunningham committed Apr 26, 2024
1 parent 1725139 commit 2659704
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions airflow/www/security_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def get_dag_id_from_task_instance(resource_pk):
if not resource_pk:
return None
composite_pk = json.loads(resource_pk)
ti = session.scalar(
select(DagRun)
dag_id = session.scalar(
select(TaskInstance.dag_id)
.where(
TaskInstance.dag_id == composite_pk[0],
TaskInstance.task_id == composite_pk[1],
Expand All @@ -209,9 +209,9 @@ def get_dag_id_from_task_instance(resource_pk):
)
.limit(1)
)
if not ti:
if not dag_id:
raise AirflowException("Task instance not found")
return ti.dag_id
return dag_id

def get_pool_name(resource_pk):
if not resource_pk:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ norecursedirs = [
log_level = "INFO"
filterwarnings = [
"error::pytest.PytestCollectionWarning",
# Avoid building cartesian product which might impact performance
"error:SELECT statement has a cartesian product between FROM:sqlalchemy.exc.SAWarning:airflow",
"ignore::DeprecationWarning:flask_appbuilder.filemanager",
"ignore::DeprecationWarning:flask_appbuilder.widgets",
# https://github.com/dpgaspar/Flask-AppBuilder/pull/1940
Expand Down

0 comments on commit 2659704

Please sign in to comment.