Skip to content

Add prek hook to enforce conf import from compat SDK in providers#64564

Merged
potiuk merged 2 commits intoapache:mainfrom
jason810496:ci/conf/enforce-compact-conf-import
Apr 1, 2026
Merged

Add prek hook to enforce conf import from compat SDK in providers#64564
potiuk merged 2 commits intoapache:mainfrom
jason810496:ci/conf/enforce-compact-conf-import

Conversation

@jason810496
Copy link
Copy Markdown
Member

@jason810496 jason810496 commented Apr 1, 2026

related: #64143, #60000

Why

Providers have historically imported conf from airflow.configuration or airflow.sdk.configuration directly, which breaks cross-version compatibility between Airflow 2 and 3. We need to enforce that conf is only
imported from airflow.providers.common.compat.sdk.

What

  • Add check_conf_import_in_providers.py prek hook that uses AST-based import analysis to detect forbidden conf imports from airflow.configuration and airflow.sdk.configuration in provider source files.
  • Catches imports at all scopes: top-level, inside functions, inside TYPE_CHECKING blocks, and aliased imports.
  • Excludes the compat SDK module itself (common/compat/sdk.py) which legitimately re-exports conf.
  • Register the hook in providers/.pre-commit-config.yaml targeting ^.*/src/airflow/providers/.*\.py$.
  • Add parametrized tests covering forbidden and allowed import patterns.
Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below) Claude Code following the guidelines

@boring-cyborg boring-cyborg bot added area:dev-tools area:providers backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch labels Apr 1, 2026
@potiuk potiuk merged commit c3838a4 into apache:main Apr 1, 2026
67 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 1, 2026
…roviders (#64564)

* Add prek hook to enforce conf import from compat SDK in providers

* Add executor file checks for allowed configuration imports
(cherry picked from commit c3838a4)

Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

Backport successfully created: v3-2-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test PR Link

potiuk pushed a commit that referenced this pull request Apr 1, 2026
…roviders (#64564) (#64567)

* Add prek hook to enforce conf import from compat SDK in providers

* Add executor file checks for allowed configuration imports
(cherry picked from commit c3838a4)

Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
@jscheffl
Copy link
Copy Markdown
Contributor

jscheffl commented Apr 1, 2026

Cool!

potiuk added a commit to potiuk/airflow that referenced this pull request Apr 1, 2026
potiuk added a commit that referenced this pull request Apr 1, 2026
Subham-KRLX pushed a commit to Subham-KRLX/airflow that referenced this pull request Apr 3, 2026
…ache#64564)

* Add prek hook to enforce conf import from compat SDK in providers

* Add executor file checks for allowed configuration imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools area:providers backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants