Fix HttpAsyncHook crash on stream/cert/trust_env connection extras - #71524
Open
gtxu wants to merge 1 commit into
Open
Fix HttpAsyncHook crash on stream/cert/trust_env connection extras#71524gtxu wants to merge 1 commit into
gtxu wants to merge 1 commit into
Conversation
gtxu
force-pushed
the
fix-http-async-hook-extra-options
branch
from
August 13, 2026 01:09
12f9ae6 to
917840d
Compare
gtxu
marked this pull request as ready for review
August 13, 2026 01:10
HttpAsyncHook shares its extra-options parsing with the synchronous HttpHook, but the shared helper's output is requests-flavored and gets forwarded as-is into aiohttp's request call. aiohttp rejects stream, cert, and trust_env as unexpected keyword arguments, so any HTTP connection carrying one of those keys in its Extra field crashed every async request. check_response was accepted into the same dict but never actually consumed on the async side, so it silently had no effect unlike the synchronous path's run_and_check().
gtxu
force-pushed
the
fix-http-async-hook-extra-options
branch
from
August 13, 2026 01:42
917840d to
6de7bc3
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.
HttpAsyncHook/AsyncHttpSession.run()shares_process_extra_options_from_connection()with the syncHttpHook, but that function's output usesrequests-flavored option names, and the async path blindly forwards all of them as kwargs intoaiohttp.ClientSession's request call.aiohttpdoesn't acceptstream,cert, ortrust_envas request kwargs at all, so any HTTP connection with one of those three keys set in itsExtrafield — or passed viaextra_options=at call time — crashed every single request withTypeError: request() got an unexpected keyword argument '...'. This affects both direct HttpAsyncHook usage and Airflow's deferred/async HTTP triggers, since they route through the same code path.Separately,
check_response(meant to suppressraise_for_status()on non-2xx responses, matching sync'srun_and_check()) was accepted into the same shared dict but never actually consumed on the async side —AsyncHttpSession.run()alwayscalled raise_for_status()unconditionally, so settingcheck_response: falsehad no effect on async requests.Fix:
AsyncHttpSession.run()now popscheck_responseand honors it before callingraise_for_status(), bringing async to parity with sync's existing behavior.stream,cert, andtrust_envare filtered out before the aiohttp call, with a warning logged listing which were dropped. These three have no aiohttp equivalent worth implementing here: aiohttp streams responses by default (nostreamflag needed), andcert/trust_envwould require real work (building anssl.SSLContext, restructuring session construction) that's out of scope for a crash fix.trust_envgets passed through to the aiohttp mock — it only passed because the plainAsyncMockdoesn't validate kwargs against aiohttp's real method signature, which is exactly how this bug went undetected.Test plan:
stream/cert/trust_envnever reach the aiohttp call (with the warning logged) and thatcheck_response: falsesuppressesraise_for_status()on async requests.providers-tests --test-type "Providers[http]"suite, mypy, and ruff all pass.Drafted-by: Claude Code (Sonnet 5) Reviewed-by: @gtxu before submission
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 5) following the guidelines