Skip to content

Extract seams for Dag processor callback fetching to allow DB-to-API swap#65543

Open
ephraimbuddy wants to merge 4 commits intoapache:mainfrom
astronomer:refactor-callback-fetching
Open

Extract seams for Dag processor callback fetching to allow DB-to-API swap#65543
ephraimbuddy wants to merge 4 commits intoapache:mainfrom
astronomer:refactor-callback-fetching

Conversation

@ephraimbuddy
Copy link
Copy Markdown
Contributor

@ephraimbuddy ephraimbuddy commented Apr 20, 2026

Introduce two seams in DagFileProcessorManager callback handling so metadata-DB access can later be swapped for API calls:

  • fetch_callbacks() — the outer seam; default delegates to the DB-backed _fetch_callbacks().
  • prepare_callback_bundle(request) -> BaseDagBundle | None — resolves the bundle for a callback request and, for versioned requests on bundles that support versioning, calls bundle.initialize(). Returns None to signal the callback should be skipped (bundle no longer configured, or initialization failed).

_add_callback_to_queue checks the returned bundle and skips on None. No behavior change for the default DB-backed flow — log messages and skip semantics are preserved.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Generated-by: claude opus 4.7

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Dag processor manager’s callback-fetching/queuing flow to introduce overrideable “seams” so the default metadata-DB callback source can later be swapped for an API-backed implementation, without changing the DB-backed behavior.

Changes:

  • Adds fetch_callbacks() as the outer callback-fetching seam (default delegates to the existing DB implementation).
  • Extracts bundle resolution and bundle initialization into resolve_callback_bundle() and initialize_callback_bundle().
  • Updates/extends unit tests to cover the new seams and initialization failure behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
airflow-core/src/airflow/dag_processing/manager.py Introduces fetch_callbacks/resolve_callback_bundle/initialize_callback_bundle and routes the parsing loop through the new seam methods.
airflow-core/tests/unit/dag_processing/test_manager.py Updates existing callback-fetch test docstring and adds unit tests for the new seam methods.

Comment thread airflow-core/tests/unit/dag_processing/test_manager.py
Comment thread airflow-core/tests/unit/dag_processing/test_manager.py Outdated
Comment thread airflow-core/tests/unit/dag_processing/test_manager.py Outdated
Comment thread airflow-core/tests/unit/dag_processing/test_manager.py
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
@ephraimbuddy ephraimbuddy force-pushed the refactor-callback-fetching branch from d949bea to 4abdbb6 Compare April 21, 2026 09:25
…swap

Split the DagFileProcessorManager callback path into discrete methods so
metadata-DB access can be swapped for API calls:

- fetch_callbacks() — the outer seam; default hits the DB
- resolve_callback_bundle() — bundle lookup
- initialize_callback_bundle() — bundle preparation, returning whether the
callback can proceed

No behavior change for the default DB-backed flow.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/src/airflow/dag_processing/manager.py
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/src/airflow/dag_processing/manager.py Outdated
Comment thread airflow-core/tests/unit/dag_processing/test_manager.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@ephraimbuddy ephraimbuddy self-assigned this Apr 22, 2026
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.

5 participants