diff --git a/airflow-core/src/airflow/models/connection.py b/airflow-core/src/airflow/models/connection.py index 0e1505f4667dd..d58f2b3202dbd 100644 --- a/airflow-core/src/airflow/models/connection.py +++ b/airflow-core/src/airflow/models/connection.py @@ -32,7 +32,6 @@ from airflow._shared.module_loading import import_string from airflow._shared.secrets_masker import mask_secret -from airflow.configuration import conf, ensure_secrets_loaded from airflow.exceptions import AirflowException, AirflowNotFoundException from airflow.models.base import ID_LEN, Base from airflow.models.crypto import get_fernet @@ -528,6 +527,8 @@ def get_connection_from_secrets(cls, conn_id: str, team_name: str | None = None) raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined") from None raise + from airflow.configuration import conf, ensure_secrets_loaded + if team_name and not conf.getboolean("core", "multi_team"): raise ValueError( "Multi-team mode is not configured in the Airflow environment but the task trying to access the connection belongs to a team"