amoghrajesh commented on code in PR #47648:
URL: https://github.com/apache/airflow/pull/47648#discussion_r1992860150


##########
airflow/models/connection.py:
##########
@@ -473,8 +473,18 @@ def get_connection_from_secrets(cls, conn_id: str) -> 
Connection:
                 if 
hasattr(sys.modules.get("airflow.sdk.execution_time.task_runner"), 
"SUPERVISOR_COMMS"):
                     # TODO: AIP 72: Add deprecation here once we move this 
module to task sdk.
                     from airflow.sdk import Connection as TaskSDKConnection
-
-                    return TaskSDKConnection.get(conn_id=conn_id)
+                    from airflow.sdk.exceptions import AirflowRuntimeError, 
ErrorType

Review Comment:
   Thanks for making this change. I added some tests in the original PR #47593, 
could you add a case there too?



##########
airflow/models/connection.py:
##########
@@ -473,8 +473,18 @@ def get_connection_from_secrets(cls, conn_id: str) -> 
Connection:
                 if 
hasattr(sys.modules.get("airflow.sdk.execution_time.task_runner"), 
"SUPERVISOR_COMMS"):
                     # TODO: AIP 72: Add deprecation here once we move this 
module to task sdk.
                     from airflow.sdk import Connection as TaskSDKConnection
-
-                    return TaskSDKConnection.get(conn_id=conn_id)
+                    from airflow.sdk.exceptions import AirflowRuntimeError, 
ErrorType
+
+                    try:
+                        return TaskSDKConnection.get(conn_id=conn_id)
+                    except AirflowRuntimeError as e:
+                        if e.error.error == ErrorType.CONNECTION_NOT_FOUND:
+                            log.exception(
+                                "Unable to retrieve connection from 
MetastoreBackend using Task SDK"
+                            )

Review Comment:
   I like it, lets keep the log. Gives more info as to whats happening.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to