Skip to content

Pass ClientTimeout to aiohttp in Cloud Composer async hook - #74164

Merged
shahar1 merged 1 commit into
apache:mainfrom
shahar1:fix-composer-aiohttp-client-timeout
Oct 3, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
shahar1:fix-composer-aiohttp-client-timeout

Conversation

@shahar1

@shahar1 shahar1 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

related: #74151

This PR passes ClientTimeout explicitly to aiohttp in Cloud Composer async hook.
This fix is simple yet required to appease mypy when upgrading to Python 3.11.

AI Summary

CloudComposerAsyncHook.make_composer_airflow_api_request passed its timeout: float | None straight to aiohttp.ClientSession.request. aiohttp only types the request keyword arguments when type-checking on Python 3.11+ (if sys.version_info >= (3, 11) and TYPE_CHECKING: ... **kwargs: Unpack[_RequestOptions]), where timeout is ClientTimeout | _SENTINEL | None. On 3.10 the kwargs are Any, so the mismatch went unnoticed until #74151 moved CI (and mypy) to Python 3.11:

providers/google/src/airflow/providers/google/cloud/hooks/cloud_composer.py:613: error: Argument "timeout" to "request" of "ClientSession" has incompatible type "float | None"; expected "ClientTimeout | _SENTINEL | None"  [arg-type]

The fix wraps the value in ClientTimeout(total=timeout). This is exactly what aiohttp already does at runtime for a non-ClientTimeout value (real_timeout = ClientTimeout(total=timeout)), so behaviour is unchanged, including None meaning no total timeout. A unit test for the async request method (which had none) asserts the ClientTimeout that reaches session.request for both a float and None; it fails without the change.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

🤖 Generated with Claude Code

aiohttp types the keyword arguments of ClientSession.request only when
type-checking on Python 3.11 or newer, where timeout must be a
ClientTimeout. On 3.10 the arguments are untyped, so passing the hook's
float timeout went unnoticed until CI moved to Python 3.11. aiohttp
already converts a bare number to ClientTimeout(total=...) at runtime,
so building it explicitly keeps the behaviour and satisfies mypy.
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Oct 3, 2026
@shahar1
shahar1 requested a review from dabla October 3, 2026 14:53
@shahar1
shahar1 merged commit e4736b4 into apache:main Oct 3, 2026
87 checks passed
@shahar1
shahar1 deleted the fix-composer-aiohttp-client-timeout branch October 3, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants