Skip to content

Callback queueing skips versioned bundle initialization when DagCallbackRequest.bundle_version is None #64891

Closed

Description

@hkc-8010

Summary

DagFileProcessorManager._add_callback_to_queue() only initializes a versioned bundle when request.bundle_version is truthy.

That means DAG callback requests created with bundle_version=None can still be queued, but DagFileInfo is constructed from bundle.path before the bundle has been initialized or refreshed.

bundle = DagBundlesManager().get_bundle(name=request.bundle_name, version=request.bundle_version)
...
if bundle.supports_versioning and request.bundle_version:
    bundle.initialize()
...
file_info = DagFileInfo(
    rel_path=Path(request.filepath),
    bundle_path=bundle.path,
    bundle_name=request.bundle_name,
    bundle_version=request.bundle_version,
)

This is especially visible when DAG-level callbacks are produced from a DagRun with bundle_version=None, for example when disable_bundle_versioning=True is enabled.

Why this looks like an Airflow bug

DagRun.produce_dag_callback() copies self.bundle_version directly into DagCallbackRequest.bundle_version.

So when bundle versioning is disabled, callback requests are expected to have bundle_version=None.

In that case, callback queueing currently assumes it is still safe to use bundle.path without initialization. That is not a safe assumption for versioned bundle implementations whose usable path is only known after initialize() / refresh().

Even if some concrete failures are bundle-backend-specific, the callback queueing logic itself appears incomplete: it does not define how callback-only processing should resolve a versioned bundle when bundle_version is intentionally absent.

Observed behavior

In a real Airflow 3.1.8 / Astro Hosted investigation, this produced callback-only processing like:

Detected callback-only processing for DagFileInfo(..., bundle_path=PosixPath('/dev/null'), bundle_version=None)

The underlying bundle backend there exposed /dev/null before initialization, but the more general problem is that callback queueing skipped bundle initialization entirely because request.bundle_version was falsy.

Expected behavior

If a callback request targets a versioned bundle but bundle_version is None, callback queueing should still resolve a usable bundle path before constructing DagFileInfo.

Possible expected behaviors:

  • initialize the bundle whenever bundle.supports_versioning, even when request.bundle_version is None
  • or explicitly define a fallback path for callback-only processing that resolves the current effective bundle version/context
  • or reject the callback request explicitly instead of silently proceeding with an unresolved bundle.path

Actual behavior

Callback queueing can proceed with an unresolved bundle path when all of the following are true:

  • the bundle supports versioning
  • the callback request has bundle_version=None
  • the bundle implementation requires initialize() / refresh() before path is usable

Relevant code paths

  • airflow.models.dagrun.DagRun.produce_dag_callback()
  • airflow.dag_processing.manager.DagFileProcessorManager._add_callback_to_queue()

Version

Observed on Airflow 3.1.8.

Additional context

I am also filing the backend-specific half of this in Astronomer's bundle backend repo, because one concrete manifestation used a backend whose unresolved path was /dev/null. But this issue is about the upstream callback queueing contract when bundle_version=None is intentional.

Activity

  1. added
    kind:bug
    priority:medium
    on Apr 8, 2026
  2. added a commit that references this issue on Apr 9, 2026
    5895bde
  3. shivaam commented on Apr 9, 2026

    @shivaam
    Contributor

    Opened a pull request: #64942

  4. nikolauspschuetz commented on Jun 26, 2026

    @nikolauspschuetz
    Contributor

    I'd like to pick this up. Confirmed it still reproduces on current main: DagFileProcessorManager.prepare_callback_bundle() (airflow-core/src/airflow/dag_processing/manager.py, the if bundle.supports_versioning and request.bundle_version: guard) skips bundle.initialize() whenever request.bundle_version is None — e.g. with bundle versioning disabled. The queued DagFileInfo is then built from bundle.path before the versioned bundle has been materialized, so the Dag-level callback is dispatched against an uninitialized bundle path.

    Proposed direction: for bundles where supports_versioning is true, initialize the bundle before reading bundle.path even when bundle_version is None (resolving to the current/"latest" materialized version), while leaving non-versioning bundles untouched. I'll add a unit test in test_manager.py asserting the bundle is initialized and the queued DagFileInfo carries the initialized path for the bundle_version=None case (the topology-dependent end-to-end repro from the linked #52040 thread isn't practical in CI, so the unit test pins the behavior).

    The earlier PR #64942 was closed for inactivity; I'll open a fresh PR rather than reviving it, scoping the condition carefully so versioned bundles that do carry an explicit version keep their current behavior. Does that direction look right?


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

  5. added a commit that references this issue on Sep 18, 2026
    b6d67b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corearea:dag-bundleskind:bugpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions