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

Replace deprecated get_accessible_dag_ids and use get_readable_dags in get_dag_warnings #36256

Merged
merged 1 commit into from
Dec 16, 2023
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
5 changes: 2 additions & 3 deletions airflow/api_connexion/endpoints/dag_warning_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

from typing import TYPE_CHECKING

from flask import g
from sqlalchemy import select

from airflow.api_connexion import security
Expand All @@ -27,9 +26,9 @@
DagWarningCollection,
dag_warning_collection_schema,
)
from airflow.api_connexion.security import get_readable_dags
from airflow.auth.managers.models.resource_details import DagAccessEntity
from airflow.models.dagwarning import DagWarning as DagWarningModel
from airflow.utils.airflow_flask_app import get_airflow_app
from airflow.utils.db import get_query_count
from airflow.utils.session import NEW_SESSION, provide_session

Expand Down Expand Up @@ -61,7 +60,7 @@ def get_dag_warnings(
if dag_id:
query = query.where(DagWarningModel.dag_id == dag_id)
else:
readable_dags = get_airflow_app().appbuilder.sm.get_accessible_dag_ids(g.user)
readable_dags = get_readable_dags()
query = query.where(DagWarningModel.dag_id.in_(readable_dags))
if warning_type:
query = query.where(DagWarningModel.warning_type == warning_type)
Expand Down
4 changes: 2 additions & 2 deletions airflow/api_connexion/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,5 @@ def decorated(*args, **kwargs):
return requires_access_decorator


def get_readable_dags() -> list[str]:
return get_airflow_app().appbuilder.sm.get_accessible_dag_ids(g.user)
def get_readable_dags() -> set[str]:
return get_auth_manager().get_permitted_dag_ids(user=g.user)