Repository navigation
Description
Summary
TriggerRunner.get_trigger_by_classpath() calls importlib.import_module() against an unmodified sys.path that never includes the active DAG bundle root (e.g., dags/). This means any trigger that imports a helper module stored inside the bundle fails with ModuleNotFoundError at deserialization time.
PR #55894 fixed this gap for the DagBag parsing path, the worker (task runner), the DAG processor, and the CLI — but the Triggerer subprocess was missed entirely.
Affected version(s)
Airflow 3.x (3.1.x, 3.2+). Airflow 2.x is not affected because DAG bundles are a 3.x concept.
What happened
A trigger whose serialize() return value includes a classpath pointing into dags/ (e.g., helpers.emr_sensor_helpers.MyTrigger) raises:
ModuleNotFoundError: No module named 'helpers'
in the Triggerer subprocess even after PR #55894 landed (Airflow 3.1.7 / 3.1.8), because the triggerer process never adds the bundle root to sys.path.
Root cause (code path)
TriggerRunnerSupervisor._create_workload()
→ workloads.RunTrigger(classpath=..., ...) # no bundle_info field
TriggerRunnerSupervisor → subprocess: messages.StartTriggerer() # no bundle info
TriggerRunner.create_triggers()
→ self.get_trigger_by_classpath(workload.classpath)
→ import_string(classpath)
→ importlib.import_module(...) # sys.path has no bundle root → ModuleNotFoundError
Key files:
airflow-core/src/airflow/jobs/triggerer_job_runner.py—TriggerRunner.get_trigger_by_classpath()(line ~1346),create_triggers()(line ~1081),_create_workload()(line ~672)airflow-core/src/airflow/executors/workloads/trigger.py—RunTriggerhas nobundle_infofield
What the task runner already does (correct pattern)
ExecuteTask (the task workload) carries a BundleInfo field. The task runner subprocess receives it in StartupDetails, calls DagBundlesManager().get_bundle(...), calls bundle.initialize(), and appends the path to sys.path before executing user code.
The Triggerer needs the same treatment.
Proposed fix
- Add
bundle_info: BundleInfo | None = NonetoRunTriggerworkload (mirrorsBaseDagBundleWorkloadpattern). - Populate it in
TriggerRunnerSupervisor._create_workload()fromtrigger.task_instance.dag_model.bundle_name/trigger.task_instance.dag_run.bundle_versionwhen atask_instanceis present. Asset-based triggers (notask_instance) leave itNone. - Add
TriggerRunner._ensure_bundle_on_syspath(bundle_info)that callsDagBundlesManager().get_bundle(...),bundle.initialize(), and appends the path tosys.path(with deduplication), mirroring the callback-supervisor pattern intask-sdk/src/airflow/sdk/execution_time/supervisor.py:~167. - Call
_ensure_bundle_on_syspathincreate_triggers()beforeget_trigger_by_classpath().
Impact
Any Airflow 3.x deployment where trigger classes import helper modules stored inside dags/ is affected. This is particularly acute for Astro dags-only deploys, where helpers cannot be moved to include/ without requiring a full image rebuild on every code change — eliminating the main benefit of the dags-only deploy workflow.
Activity
Fix triggerer subprocess unable to import helpers from DAG bundle root
hkc-8010 commentedon May 18, 2026
Closing this as wontfix.