You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "mfatemipour (via GitHub)" <gi...@apache.org> on 2026/05/13 07:33:50 UTC
[I] get_async_connection hard-codes BaseHook.aget_connection, bypassing subclass overrides [airflow]
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: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] get_async_connection hard-codes BaseHook.aget_connection, bypassing subclass overrides [airflow]
Posted by "dabla (via GitHub)" <gi...@apache.org>.
dabla closed issue #66845: get_async_connection hard-codes BaseHook.aget_connection, bypassing subclass overrides
URL: https://github.com/apache/airflow/issues/66845
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] get_async_connection hard-codes BaseHook.aget_connection, bypassing subclass overrides [airflow]
Posted by "jroachgolf84 (via GitHub)" <gi...@apache.org>.
jroachgolf84 commented on issue #66845:
URL: https://github.com/apache/airflow/issues/66845#issuecomment-4440944083
@mfatemipour, can you share the code that you authored (or a snip of it)? I think this will help us troubleshoot a bit further. At face value, the currently implementation of `get_async_connection` is not a problem. I'd be curious to see what you've written.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org