Skip to content

Respect async connection hook overrides#67440

Closed
bobu-putheeckal wants to merge 1 commit into
apache:mainfrom
bobu-putheeckal:codex-airflow-66845-async-connection-overrides
Closed

Respect async connection hook overrides#67440
bobu-putheeckal wants to merge 1 commit into
apache:mainfrom
bobu-putheeckal:codex-airflow-66845-async-connection-overrides

Conversation

@bobu-putheeckal

@bobu-putheeckal bobu-putheeckal commented May 24, 2026

Copy link
Copy Markdown

Fixes: #66845

This PR fixes a narrow async hook dispatch issue in provider connection handling.

Problem

airflow.providers.common.compat.connection.get_async_connection() always resolved connections through BaseHook. That means async hooks which intentionally override aget_connection() or get_connection() on a subclass can be bypassed when code reaches the shared async helper.

The issue report calls this out for async provider hooks: subclass-specific connection resolution should still be honored in the async path.

What changed

  • get_async_connection() now accepts an optional hook_class argument.
  • The default remains BaseHook, preserving behavior for existing callers.
  • HttpAsyncHook.config() passes type(self) so subclass aget_connection() / get_connection() overrides are reached through normal classmethod dispatch.
  • Added focused regression coverage in the common compat provider and HTTP provider tests.

Validation

I ran these checks locally:

uv run --project providers/common/compat --group dev pytest providers/common/compat/tests/unit/common/compat/connection/test_connection.py
# 4 passed

uv run --project providers/http --group dev pytest providers/http/tests/unit/http/hooks/test_http.py::TestHttpAsyncHook::test_config_uses_subclass_aget_connection
# 1 passed

uv run --project providers/http --group dev ruff format providers/common/compat/src/airflow/providers/common/compat/connection/__init__.py providers/common/compat/tests/unit/common/compat/connection/test_connection.py providers/http/src/airflow/providers/http/hooks/http.py providers/http/tests/unit/http/hooks/test_http.py
# 4 files unchanged

uv run --project providers/http --group dev ruff check providers/common/compat/src/airflow/providers/common/compat/connection/__init__.py providers/common/compat/tests/unit/common/compat/connection/test_connection.py providers/http/src/airflow/providers/http/hooks/http.py providers/http/tests/unit/http/hooks/test_http.py
# all checks passed

No UI behavior is changed, so screenshots are not applicable.


Was generative AI tooling used to co-author this PR?
  • Yes: OpenAI Codex. I reviewed the generated changes and ran the focused tests listed above.

Generated-by: OpenAI Codex following https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

@kaxil

kaxil commented May 24, 2026

Copy link
Copy Markdown
Member

AI Spam! Review your PR descriptions!

@bobu-putheeckal

Copy link
Copy Markdown
Author

Thanks, you are right that the previous description was not good enough. I rewrote it to describe the concrete bug, the code path changed, and the exact local validation results. I will slow down and avoid batch-style Airflow submissions going forward.

@bobu-putheeckal
bobu-putheeckal marked this pull request as draft May 25, 2026 00:58
@bobu-putheeckal

Copy link
Copy Markdown
Author

I also moved this to draft so it is not sitting in the review queue while I make sure the description and evidence meet the project expectations.

@potiuk

potiuk commented Jun 25, 2026

Copy link
Copy Markdown
Member

@bobu-putheeckal — closing this for now since it's a draft that's been inactive for a few weeks. This is purely housekeeping to keep the review queue tidy — not a reflection on the change itself.

When you're ready to pick it back up, just reopen this PR (or open a fresh one), rebase onto the latest main, and mark it Ready for review. There's no rush, and thanks for the contribution!

See the PR quality criteria.

Automated triage note drafted by an AI-assisted tool — may get things wrong; a real Apache Airflow maintainer is happy to help if you reopen. (why automated)


Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_async_connection hard-codes BaseHook.aget_connection, bypassing subclass overrides

3 participants