From faef91d15d5e1a8399cf38aa2e25c1f14f9a5a09 Mon Sep 17 00:00:00 2001 From: Ramit Kataria Date: Wed, 7 May 2025 17:08:52 -0700 Subject: [PATCH 1/2] Fix consistency in exception/log handling in `connection.py` In one of my previus PRs (#47648), I incorrectly assumed that catching the exception from `secrets_backend.get_connection` was meant for the connection not found case. So, I'm reversing a couple of changes from that PR for consistency. --- airflow-core/src/airflow/models/connection.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/airflow-core/src/airflow/models/connection.py b/airflow-core/src/airflow/models/connection.py index d83b687c76dad..85485953ebf46 100644 --- a/airflow-core/src/airflow/models/connection.py +++ b/airflow-core/src/airflow/models/connection.py @@ -478,7 +478,6 @@ def get_connection_from_secrets(cls, conn_id: str) -> Connection: return conn except AirflowRuntimeError as e: if e.error.error == ErrorType.CONNECTION_NOT_FOUND: - log.debug("Unable to retrieve connection from MetastoreBackend using Task SDK") raise AirflowNotFoundException(f"The conn_id `{conn_id}` isn't defined") raise @@ -498,8 +497,8 @@ def get_connection_from_secrets(cls, conn_id: str) -> Connection: SecretCache.save_connection_uri(conn_id, conn.get_uri()) return conn except Exception: - log.debug( - "Unable to retrieve connection from secrets backend (%s). " + log.exception( + "Error while retrieving connection from secrets backend (%s). " "Checking subsequent secrets backend.", type(secrets_backend).__name__, ) From 7d3a2d67a1a35bab07d52ef0a1457e3374f54448 Mon Sep 17 00:00:00 2001 From: Ramit Kataria Date: Fri, 9 May 2025 10:33:43 -0700 Subject: [PATCH 2/2] Change log message --- airflow-core/src/airflow/models/connection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow-core/src/airflow/models/connection.py b/airflow-core/src/airflow/models/connection.py index 85485953ebf46..d247c9e4b7abc 100644 --- a/airflow-core/src/airflow/models/connection.py +++ b/airflow-core/src/airflow/models/connection.py @@ -498,7 +498,7 @@ def get_connection_from_secrets(cls, conn_id: str) -> Connection: return conn except Exception: log.exception( - "Error while retrieving connection from secrets backend (%s). " + "Unable to retrieve connection from secrets backend (%s). " "Checking subsequent secrets backend.", type(secrets_backend).__name__, )