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 <uranusjr@gmail.com>
  • Loading branch information
Taragolis and uranusjr authored Apr 11, 2024
1 parent 5ff2658 commit e16dc0f
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 @@ -464,6 +464,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",
# FAB do not support SQLAclhemy 2
Expand Down

0 comments on commit e16dc0f

Please sign in to comment.