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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@


if AIRFLOW_V_3_0_PLUS:
from airflow.sdk.exceptions import AirflowRuntimeError
from airflow.sdk.exceptions import AirflowRuntimeError, ErrorType

if TYPE_CHECKING:
from aiobotocore.session import AioSession
Expand Down Expand Up @@ -623,19 +623,16 @@ def conn_config(self) -> AwsConnectionWrapper:
"""Get the Airflow Connection object and wrap it in helper (cached)."""
connection = None
if self.aws_conn_id:
possible_exceptions: tuple[type[Exception], ...]

if AIRFLOW_V_3_0_PLUS:
possible_exceptions = (AirflowNotFoundException, AirflowRuntimeError)
else:
possible_exceptions = (AirflowNotFoundException,)

try:
connection = self.get_connection(self.aws_conn_id)
except possible_exceptions as e:
if isinstance(
e, AirflowNotFoundException
) or f"Connection with ID {self.aws_conn_id} not found" in str(e):
except Exception as e:
not_found_exc_via_core = isinstance(e, AirflowNotFoundException)
not_found_exc_via_task_sdk = (
AIRFLOW_V_3_0_PLUS
and isinstance(e, AirflowRuntimeError)
and e.error.error == ErrorType.CONNECTION_NOT_FOUND
)
if not_found_exc_via_core or not_found_exc_via_task_sdk:
self.log.warning(
"Unable to find AWS Connection ID '%s', switching to empty.", self.aws_conn_id
)
Expand Down