You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hkc-8010 (via GitHub)" <gi...@apache.org> on 2026/04/18 06:21:09 UTC
[I] Triggerer subprocess cannot import helpers from DAG bundle root (sys.path gap) [airflow]
hkc-8010 opened a new issue, #65455:
URL: https://github.com/apache/airflow/issues/65455
## 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` — `RunTrigger` has no `bundle_info` field
## 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
1. Add `bundle_info: BundleInfo | None = None` to `RunTrigger` workload (mirrors `BaseDagBundleWorkload` pattern).
2. Populate it in `TriggerRunnerSupervisor._create_workload()` from `trigger.task_instance.dag_model.bundle_name` / `trigger.task_instance.dag_run.bundle_version` when a `task_instance` is present. Asset-based triggers (no `task_instance`) leave it `None`.
3. Add `TriggerRunner._ensure_bundle_on_syspath(bundle_info)` that calls `DagBundlesManager().get_bundle(...)`, `bundle.initialize()`, and appends the path to `sys.path` (with deduplication), mirroring the callback-supervisor pattern in `task-sdk/src/airflow/sdk/execution_time/supervisor.py:~167`.
4. Call `_ensure_bundle_on_syspath` in `create_triggers()` before `get_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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggerer subprocess cannot import helpers from DAG bundle root (sys.path gap) [airflow]
Posted by "hkc-8010 (via GitHub)" <gi...@apache.org>.
hkc-8010 commented on issue #65455:
URL: https://github.com/apache/airflow/issues/65455#issuecomment-4480108739
Closing this as wontfix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Triggerer subprocess cannot import helpers from DAG bundle root (sys.path gap) [airflow]
Posted by "hkc-8010 (via GitHub)" <gi...@apache.org>.
hkc-8010 closed issue #65455: Triggerer subprocess cannot import helpers from DAG bundle root (sys.path gap)
URL: https://github.com/apache/airflow/issues/65455
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org