Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix built query with implicit cartessian product in AirflowSecurityManagerV2 #38913

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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