Honor async hook subclass overrides in get_async_connection#69140
Open
anxkhn wants to merge 2 commits into
Open
Honor async hook subclass overrides in get_async_connection#69140anxkhn wants to merge 2 commits into
anxkhn wants to merge 2 commits into
Conversation
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>
3a65843 to
f4e4553
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_async_connectionresolved the connection through the literalBaseHookclass, so a hook that overrides
aget_connection/get_connectionwas ignored inthe 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. Theasync path called the module helper, which hard-coded
BaseHook.aget_connectionand only took a
conn_id, so it could never see a subclass override. A user whosubclasses
HttpAsyncHookand overridesaget_connectionto injecthost/login/etc. gets correct fields on the worker but empty fields in the
triggerer.
This adds an optional
hookparameter so the helper dispatches through thecalling hook (defaulting to
BaseHook, so all existing callers are unchanged),and passes the hook from
HttpAsyncHook. Custom subclasses now behave the samein 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
mainandready for review.
closes: #66845
Was generative AI tooling used to co-author this PR?