Skip to content

Honor async hook subclass overrides in get_async_connection#69140

Merged
dabla merged 5 commits into
apache:mainfrom
anxkhn:loop/airflow__002
Jul 16, 2026
Merged

Honor async hook subclass overrides in get_async_connection#69140
dabla merged 5 commits into
apache:mainfrom
anxkhn:loop/airflow__002

Conversation

@anxkhn

@anxkhn anxkhn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

anxkhn commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, all four addressed:

  1. Log message: both branches now log the actual resolving hook via %s. I compute the name as hook.__name__ if isinstance(hook, type) else type(hook).__name__ rather than a bare hook.__name__, since points 2 and 3 let hook be an instance and a bare .__name__ would raise on instances.
  2. Typing: widened to BaseHook | type[BaseHook] | None.
  3. type(self) -> self: switched to self; the helper handles an instance throughout, and passing the instance preserves instance-specific behavior, which is the worker/triggerer parity this PR is after.
  4. Added test_get_async_connection_honors_passed_hook_get_connection, mirroring the async one; it exercises the sync_to_async branch and fails without the fix.

ruff, ruff-format, mypy, and the compat connection test module pass locally.

@anxkhn
anxkhn requested review from SameerMesiah97 and dabla July 2, 2026 19:21
@dabla

dabla commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@anxkhn Check the ci/cd failure, yoiu need to add the # use next version, think we are almost there.

…bump

The http provider's common-compat lower bound was manually bumped to
1.16.0, which selective-checks rejects since only Release Managers set
exact >= versions for provider dependencies. Restore the existing
lower bound and mark it with '# use next version' so the dependency
resolves correctly once common.compat's next release ships, per
contributing-docs/13_airflow_dependencies_and_extras.rst.

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 8, 2026
@dabla
dabla merged commit b6f140e into apache:main Jul 16, 2026
104 checks passed
shahar1 added a commit to shahar1/airflow that referenced this pull request Jul 23, 2026
The http provider calls get_async_connection(hook=...), a parameter added by
apache#69140 that has never been released. common.compat was left out of the wave, so
the '# use next version' marker resolved to the already-published 1.16.0, whose
signature does not accept it — installing http 6.0.5 alongside common-compat
1.16.0 raises TypeError in the triggerer.

airbyte's only pending commit moves airbyte-api from the 0.x series to 1.x and
stops installing requests, excluding every previously supported version of a
hard dependency, which is a major bump rather than the patch it was given.

Four more providers carried changelog sections that did not match the commits
actually being released: cncf.kubernetes and apache.spark were each missing an
entry, and sftp and ssh referenced the tracking issue instead of the merge
request that shipped the change.
shahar1 added a commit to shahar1/airflow that referenced this pull request Jul 23, 2026
The http provider calls get_async_connection(hook=...), a parameter added by
apache#69140 that has never been released. common.compat was left out of the wave, so
the '# use next version' marker resolved to the already-published 1.16.0, whose
signature does not accept it — installing http 6.0.5 alongside common-compat
1.16.0 raises TypeError in the triggerer.

airbyte's only pending commit moves airbyte-api from the 0.x series to 1.x and
stops installing requests, excluding every previously supported version of a
hard dependency, which is a major bump rather than the patch it was given.

Four more providers carried changelog sections that did not match the commits
actually being released: cncf.kubernetes and apache.spark were each missing an
entry, and sftp and ssh referenced the tracking issue instead of the merge
request that shipped the change.
shahar1 added a commit to shahar1/airflow that referenced this pull request Jul 23, 2026
The http provider calls get_async_connection(hook=...), a parameter added by
apache#69140 that has never been released. common.compat was left out of the wave, so
the '# use next version' marker resolved to the already-published 1.16.0, whose
signature does not accept it — installing http 6.0.5 alongside common-compat
1.16.0 raises TypeError in the triggerer.

airbyte's only pending commit moves airbyte-api from the 0.x series to 1.x and
stops installing requests, excluding every previously supported version of a
hard dependency, which is a major bump rather than the patch it was given.

Four more providers carried changelog sections that did not match the commits
actually being released: cncf.kubernetes and apache.spark were each missing an
entry, and sftp and ssh referenced the tracking issue instead of the merge
request that shipped the change.
shahar1 added a commit to shahar1/airflow that referenced this pull request Jul 23, 2026
The http provider calls get_async_connection(hook=...), a parameter added by
apache#69140 that has never been released. common.compat was left out of the wave, so
the '# use next version' marker resolved to the already-published 1.16.0, whose
signature does not accept it — installing http 6.0.5 alongside common-compat
1.16.0 raises TypeError in the triggerer.

airbyte's only pending commit moves airbyte-api from the 0.x series to 1.x and
stops installing requests, excluding every previously supported version of a
hard dependency, which is a major bump rather than the patch it was given.

Four more providers carried changelog sections that did not match the commits
actually being released: cncf.kubernetes and apache.spark were each missing an
entry, and sftp and ssh referenced the tracking issue instead of the merge
request that shipped the change.
shahar1 added a commit to shahar1/airflow that referenced this pull request Jul 23, 2026
The http provider calls get_async_connection(hook=...), a parameter added by
apache#69140 that has never been released. common.compat was left out of the wave, so
the '# use next version' marker resolved to the already-published 1.16.0, whose
signature does not accept it — installing http 6.0.5 alongside common-compat
1.16.0 raises TypeError in the triggerer.

airbyte's only pending commit moves airbyte-api from the 0.x series to 1.x and
stops installing requests, excluding every previously supported version of a
hard dependency, which is a major bump rather than the patch it was given.

Four more providers carried changelog sections that did not match the commits
actually being released: cncf.kubernetes and apache.spark were each missing an
entry, and sftp and ssh referenced the tracking issue instead of the merge
request that shipped the change.
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

4 participants