Skip to content

Add aiohttp trust_env config for Snowflake async hook#67906

Open
Codingaditya17 wants to merge 1 commit into
apache:mainfrom
Codingaditya17:add-aiohttp-client-session-config
Open

Add aiohttp trust_env config for Snowflake async hook#67906
Codingaditya17 wants to merge 1 commit into
apache:mainfrom
Codingaditya17:add-aiohttp-client-session-config

Conversation

@Codingaditya17
Copy link
Copy Markdown
Contributor

Closes: #67893

Approach

This PR keeps the change focused on the Snowflake SQL API async path, which is one of the affected deferrable operator paths mentioned in the issue.

The change adds a new [aiohttp] trust_env Airflow config option with a default value of false. The Snowflake SQL API hook reads this config and includes it in the default aiohttp_session_kwargs used when creating aiohttp.ClientSession.

Explicitly provided aiohttp_session_kwargs still take precedence, so users can override the global config at the hook level when needed.

This PR also passes aiohttp_session_kwargs through SnowflakeSqlApiTrigger serialization. Without this, the operator could create the hook with async session options, but the deferrable triggerer path would lose those options when recreating the hook during polling.

What changed

  • Added [aiohttp] trust_env config support.
  • Applied the configured trust_env value in SnowflakeSqlApiHook.
  • Passed aiohttp_session_kwargs from SnowflakeSqlApiOperator into SnowflakeSqlApiTrigger.
  • Serialized aiohttp_session_kwargs in the trigger so the triggerer preserves async session options.
  • Added tests for config based trust_env, trigger serialization, trigger hook creation, and operator deferral.

Tested

uv run ruff check \
  providers/snowflake/src/airflow/providers/snowflake/hooks/snowflake_sql_api.py \
  providers/snowflake/src/airflow/providers/snowflake/operators/snowflake.py \
  providers/snowflake/src/airflow/providers/snowflake/triggers/snowflake_trigger.py \
  providers/snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py \
  providers/snowflake/tests/unit/snowflake/operators/test_snowflake.py \
  providers/snowflake/tests/unit/snowflake/triggers/test_snowflake.py

uv run pytest providers/snowflake/tests/unit/snowflake/triggers/test_snowflake.py
uv run pytest providers/snowflake/tests/unit/snowflake/operators/test_snowflake.py::TestSnowflakeSqlApiOperator
uv run pytest providers/snowflake/tests/unit/snowflake/hooks/test_snowflake_sql_api.py -k "aiohttp_session_kwargs or trust_env or async"
uv run pytest airflow-core/tests/unit/core/test_configuration.py -k "default_config or config"

@Codingaditya17 Codingaditya17 force-pushed the add-aiohttp-client-session-config branch from 47ace8e to 3d2c6de Compare June 2, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configuration support for aiohttp.ClientSession kwargs (e.g. trust_env) in deferrable operators / triggerer

1 participant