mfatemipour opened a new issue, #66845:
URL: https://github.com/apache/airflow/issues/66845

   ### Under which category would you file this issue?
   
   Airflow Core
   
   ### Apache Airflow version
   
   3.2.1
   
   ### What happened and how to reproduce it?
   
   I implemented a custom connection where I want the host, port, login, and 
password fields to always have constant values. To achieve this, I overrode the 
get_connection and aget_connection methods and injected those constant values.
   This approach works correctly for synchronous calls within my hook (i.e., 
when running on a worker). However, it does not behave as expected in 
asynchronous contexts (i.e., when running in the triggerer). In those cases, 
the connection fields appear to be empty instead of using the values I set.
   
   
   ### What you think should happen instead?
   
   I guess the root cause is in this helper function:
   ``` python
   # 
providers/common/compat/src/airflow/providers/common/compat/connection/__init__.py
   async def get_async_connection(conn_id: str) -> Connection:
      from asgiref.sync import sync_to_async
      if hasattr(BaseHook, "aget_connection"):
          return await BaseHook.aget_connection(conn_id=conn_id)          # 
hard-coded class
      return await sync_to_async(BaseHook.get_connection)(conn_id=conn_id) # 
hard-coded class
   ```
   Although aget_connection is a @classmethod, calling it through the literal 
BaseHook class short-circuits the MRO — Python dispatches straight to 
BaseHook's implementation and the subclass override is never consulted.
   
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Apache Airflow Provider(s)
   
   _No response_
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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