-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Apache Airflow version
3.0.2
If "Other Airflow 2 version" selected, which one?
No response
What happened?
The docs state that you can use the source_dag_run attribute to fetch information about a triggering DAG run when using asset-aware scheduling. However, when I try to do so this attribute doesn't seem to exist in Airflow 3, resulting in an error:
[2025-07-06, 10:52:29] ERROR - Task failed with exception: source="task"
AttributeError: 'AssetEventDagRunReferenceResult' object has no attribute 'source_dag_run'
Drilling into the AssetEventDagRunReferenceResult class I also don't see this attribute being defined (only DAG and run IDs).
What you think should happen instead?
The given example in the docs should work. The source_dag_run attribute should be available and provide access to the source DagRun instance.
How to reproduce
Code to reproduce:
import pendulum
from airflow.providers.standard.operators.python import PythonOperator
from airflow.sdk import DAG, Asset
from airflow.sdk.execution_time.comms import AssetEventDagRunReferenceResult
from airflow.sdk.execution_time.context import TriggeringAssetEventsAccessor
dataset = Asset("/data/events")
with DAG(dag_id="example_producer", start_date=pendulum.today()):
PythonOperator(
task_id="produce",
python_callable=lambda **context: print("Produce!"),
outlets=[dataset],
)
def _print_context(triggering_asset_events: TriggeringAssetEventsAccessor):
result: AssetEventDagRunReferenceResult = triggering_asset_events[dataset][0]
print(result.source_dag_run) # Errors here
with DAG(dag_id="example_consumer", schedule=[dataset], start_date=pendulum.today()):
PythonOperator(
task_id="print_context",
python_callable=_print_context,
outlets=[dataset],
)
This uses a Python function to look at the context, but accessing the source_dag_run via Jinja templating (as shown in the docs) gives the same result.
Operating System
Docker
Versions of Apache Airflow Providers
No response
Deployment
Docker-Compose
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct