Description
Airflow should provide a global supported config mechanism to pass additional kwargs to aiohttp.ClientSession at construction time. For example, an Airflow config key — e.g. [aiohttp] trust_env = True in airflow.cfg, read by a shared session factory used across all providers.
Use case/motivation
Problem
Deferrable operators that use aiohttp internally (e.g. SnowflakeSqlApiOperator, and others backed by async HTTP clients) create aiohttp.ClientSession instances without passing trust_env=True. This means they silently ignore proxy-related environment variables (HTTPS_PROXY, HTTP_PROXY, NO_PROXY) set in the execution environment.
In managed environments like AWS MWAA — where corporate proxy settings are injected via a startup script into environment variables — this causes triggers to bypass the proxy entirely and time out, while synchronous operators using requests or urllib work correctly.
Current workaround
You can set trust_env globally via a Monkey-patch of aiohttp.ClientSession.__init__ in airflow_local_settings.py:
import aiohttp
from typing import Any
_original_init = aiohttp.ClientSession.__init__
def _trust_env_init(self: aiohttp.ClientSession, *args: Any, **kwargs: Any) -> None:
kwargs.setdefault("trust_env", True)
_original_init(self, *args, **kwargs)
aiohttp.ClientSession.__init__ = _trust_env_init
This is fragile, not discoverable, and should not be necessary for what is effectively a standard proxy configuration requirement.
Environment
Version: Apache Airflow 3.x (probably also affects 2.x)
Provider: apache-airflow-providers-snowflake (and any other provider using aiohttp in triggers)
Deployment: AWS MWAA (corporate proxy injected via startup script env vars)
Impact
Any organisation running Airflow behind a corporate proxy will hit this silently — deferrable operators time out with no clear indication that proxy settings are being ignored.
Related issues
No response
Are you willing to submit a PR?
Code of Conduct
Description
Airflow should provide a global supported config mechanism to pass additional kwargs to aiohttp.ClientSession at construction time. For example, an Airflow config key — e.g.
[aiohttp] trust_env = Truein airflow.cfg, read by a shared session factory used across all providers.Use case/motivation
Problem
Deferrable operators that use
aiohttpinternally (e.g.SnowflakeSqlApiOperator, and others backed by async HTTP clients) createaiohttp.ClientSessioninstances without passingtrust_env=True. This means they silently ignore proxy-related environment variables (HTTPS_PROXY,HTTP_PROXY,NO_PROXY) set in the execution environment.In managed environments like AWS MWAA — where corporate proxy settings are injected via a startup script into environment variables — this causes triggers to bypass the proxy entirely and time out, while synchronous operators using requests or urllib work correctly.
Current workaround
You can set
trust_envglobally via a Monkey-patch ofaiohttp.ClientSession.__init__inairflow_local_settings.py:This is fragile, not discoverable, and should not be necessary for what is effectively a standard proxy configuration requirement.
Environment
Version: Apache Airflow 3.x (probably also affects 2.x)
Provider: apache-airflow-providers-snowflake (and any other provider using aiohttp in triggers)
Deployment: AWS MWAA (corporate proxy injected via startup script env vars)
Impact
Any organisation running Airflow behind a corporate proxy will hit this silently — deferrable operators time out with no clear indication that proxy settings are being ignored.
Related issues
No response
Are you willing to submit a PR?
Code of Conduct