Skip to content

Honor async hook subclass overrides in get_async_connection#69140

Open
anxkhn wants to merge 2 commits into
apache:mainfrom
anxkhn:loop/airflow__002
Open

Honor async hook subclass overrides in get_async_connection#69140
anxkhn wants to merge 2 commits into
apache:mainfrom
anxkhn:loop/airflow__002

Conversation

@anxkhn

@anxkhn anxkhn commented Jun 29, 2026

Copy link
Copy Markdown

get_async_connection resolved the connection through the literal BaseHook
class, so a hook that overrides aget_connection/get_connection was ignored in
the triggerer even though the sync path honors it on the worker.

The sync path dispatches through the instance: provider hooks call
self.get_connection(...) (e.g. HttpHook), so a subclass override wins. The
async path called the module helper, which hard-coded BaseHook.aget_connection
and only took a conn_id, so it could never see a subclass override. A user who
subclasses HttpAsyncHook and overrides aget_connection to inject
host/login/etc. gets correct fields on the worker but empty fields in the
triggerer.

This adds an optional hook parameter so the helper dispatches through the
calling hook (defaulting to BaseHook, so all existing callers are unchanged),
and passes the hook from HttpAsyncHook. Custom subclasses now behave the same
in the triggerer as on the worker.

This reopens the fix from #67440, which was closed only as inactive-draft
housekeeping (not on its merits); this PR is rebased on the latest main and
ready for review.

closes: #66845


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Just needs a few adjustments.

Please fix CI as well.

Comment thread providers/http/src/airflow/providers/http/hooks/http.py Outdated
The async connection helper resolved connections through the literal
BaseHook class, so a hook that overrides aget_connection/get_connection
was ignored in the triggerer even though the sync path honors it on the
worker. Accept the calling hook (instance or class) and dispatch through
it, defaulting to BaseHook, and pass the hook instance from HttpAsyncHook
so a custom subclass behaves the same in the triggerer as on the worker.
The debug log now names the hook that actually resolved the connection.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@anxkhn anxkhn force-pushed the loop/airflow__002 branch from 3a65843 to f4e4553 Compare June 30, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_async_connection hard-codes BaseHook.aget_connection, bypassing subclass overrides

2 participants