dabla commented on code in PR #74766:
URL: https://github.com/apache/airflow/pull/74766#discussion_r4307190986


##########
providers/common/compat/src/airflow/providers/common/compat/connection/__init__.py:
##########
@@ -43,13 +45,27 @@ async def get_async_connection(conn_id: str, hook: BaseHook 
| type[BaseHook] | N
 
     hook = hook or BaseHook
     hook_name = hook.__name__ if isinstance(hook, type) else 
type(hook).__name__
-    if hasattr(hook, "aget_connection"):
+    if hasattr(hook, "aget_connection") and not 
_aget_connection_masks_synchronously(hook):
         log.debug("Get connection using `%s.aget_connection()`.", hook_name)
         return await hook.aget_connection(conn_id=conn_id)
     log.debug("Get connection using `%s.get_connection()`.", hook_name)
     return await sync_to_async(hook.get_connection)(conn_id=conn_id)
 
 
+def _aget_connection_masks_synchronously(hook: BaseHook | type[BaseHook]) -> 
bool:
+    """
+    Return whether ``hook.aget_connection`` is the base one of an Airflow 
older than 3.3.2.
+
+    ``Connection.aextra_dejson`` came with the asynchronous secret masking in 
Airflow 3.3.2.
+    """
+    if hasattr(Connection, "aextra_dejson"):
+        return False
+    hook_class = hook if isinstance(hook, type) else type(hook)
+    return getattr(hook_class.aget_connection, "__func__", None) is getattr(
+        BaseHook.aget_connection, "__func__", object()

Review Comment:
   Good catch, thanks. Fixed in ce02e2cf31 the way you suggested: 
`_aget_connection_masks_synchronously` now reads `getattr(BaseHook, 
"aget_connection", None)` and returns `False` when it is missing, so before 3.1 
a hook's own `aget_connection` is awaited as it was before this change. 
`test_own_aget_connection_is_honored_without_base_aget_connection` covers it 
with a `BaseHook` that has no `aget_connection`, so it fails locally without 
the fix rather than only in the 2.11 and 3.0 compat jobs. Rebased on main at 
the same time.



-- 
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