Skip to content
Merged
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
3 changes: 1 addition & 2 deletions airflow-core/src/airflow/models/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -498,7 +497,7 @@ 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(
log.exception(
Copy link
Member

@kaxil kaxil May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this logexception? It was correct before since we are looping through various secret backend here

cc @ramitkataria @amoghrajesh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally changed this to log.debug in PR #47648 because I misunderstood the behaviour. secrets_backend.get_connection returns None for "not found" cases and throws exceptions only for actual errors as far as I can tell. I encountered an issue with fernet keys where not logging the exception hid the actual error, showing only "Unable to retrieve connection from secrets backend (%s). Checking subsequent secrets backend." without any stack trace or error details which made it appear like the connection was just missing.

Using log.exception ensures that when there's a genuine error accessing a secrets backend (not just a missing connection), we get the full error details for debugging. We could also just set exc_info to True and keep using log.debug but this seems important enough for most users to know in case they're running into an issue where the connection exists but airflow can't find it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramitkataria The one you changed in PR #47648 is the different one I am referring to here. You already removed log.debug line you had added in that PR in this PR on line 481. The one I linked here is the one that loops across all secrets backends

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH thanks.

"Unable to retrieve connection from secrets backend (%s). "
"Checking subsequent secrets backend.",
type(secrets_backend).__name__,
Expand Down