From 4fa6cedf0b467cc6d727c43721f8e17c8b007219 Mon Sep 17 00:00:00 2001 From: Rachana Dutta Date: Fri, 30 Jan 2026 18:03:06 +0530 Subject: [PATCH 1/3] Docs: clarify template context for asset-triggered DAGs --- airflow-core/docs/templates-ref.rst | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/airflow-core/docs/templates-ref.rst b/airflow-core/docs/templates-ref.rst index c5f3df4dde6e4..14438d2702104 100644 --- a/airflow-core/docs/templates-ref.rst +++ b/airflow-core/docs/templates-ref.rst @@ -21,6 +21,21 @@ Templates reference =================== Variables, macros and filters can be used in templates (see the :ref:`concepts:jinja-templating` section) +Asset-triggered DAGs +-------------------- + +Asset-triggered DAGs in Apache Airflow 3 differ from time-based DAGs in the +template context they provide. + +Asset-triggered DAGs do not have a logical date, and therefore do not provide +time-based context variables such as ``logical_date``, ``ds``, ``ds_nodash``, +or values derived from them. + +For asset-triggered DAGs, information related to the triggering run can be +accessed via ``dag_run``. For example, ``dag_run.run_id`` can be used to +uniquely identify a DAG run triggered by an asset event. + +.. versionadded:: 3.0.0 The following come for free out of the box with Airflow. Additional custom macros can be added globally through :doc:`administration-and-deployment/plugins`, or at a Dag level through the @@ -70,8 +85,13 @@ Variable Type Description ``{{ var.value }}`` Airflow variables. See `Airflow Variables in Templates`_ below. ``{{ var.json }}`` Airflow variables. See `Airflow Variables in Templates`_ below. ``{{ conn }}`` Airflow connections. See `Airflow Connections in Templates`_ below. -``{{ task_instance_key_str }}`` str | A unique, human-readable key to the task instance. The format is +``{{ task_instance_key_str }}`` str | A unique, human-readable key to the task instance. + | + | For time-based DAGs, the format is | ``{dag_id}__{task_id}__{ds_nodash}``. + | + | For asset-triggered DAGs, the format uses the DAG run identifier instead: + | ``{dag_id}__{task_id}__{dag_run.run_id}``. ``{{ run_id }}`` str The currently running :class:`~airflow.models.dagrun.DagRun` run ID. ``{{ dag_run }}`` DagRun The currently running :class:`~airflow.models.dagrun.DagRun`. ``{{ test_mode }}`` bool Whether the task instance was run by the ``airflow test`` CLI. From c85f2ec2442ef33feca62a896826e7dc346b1f29 Mon Sep 17 00:00:00 2001 From: Rachana Dutta Date: Fri, 30 Jan 2026 20:35:32 +0530 Subject: [PATCH 2/3] Update description of task_instance_key_str in templates ref --- airflow-core/docs/templates-ref.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow-core/docs/templates-ref.rst b/airflow-core/docs/templates-ref.rst index 36da707fcabcc..eb85e5a94dbc8 100644 --- a/airflow-core/docs/templates-ref.rst +++ b/airflow-core/docs/templates-ref.rst @@ -89,7 +89,7 @@ Variable Type Description ``{{ var.value }}`` Airflow variables. See `Airflow Variables in Templates`_ below. ``{{ var.json }}`` Airflow variables. See `Airflow Variables in Templates`_ below. ``{{ conn }}`` Airflow connections. See `Airflow Connections in Templates`_ below. -``{{ task_instance_key_str }}`` str | A unique, human-readable key to the task instance. +``{{ task_instance_key_str }}`` str | A human-readable key to the task instance. | | For time-based DAGs, the format is | ``{dag_id}__{task_id}__{ds_nodash}``. From b1c3c550e187a3e205e0821c4282b8279f602cf1 Mon Sep 17 00:00:00 2001 From: Shahar Epstein <60007259+shahar1@users.noreply.github.com> Date: Fri, 30 Jan 2026 18:06:40 +0200 Subject: [PATCH 3/3] Update airflow-core/docs/templates-ref.rst --- airflow-core/docs/templates-ref.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/airflow-core/docs/templates-ref.rst b/airflow-core/docs/templates-ref.rst index eb85e5a94dbc8..2d9aaec2f291d 100644 --- a/airflow-core/docs/templates-ref.rst +++ b/airflow-core/docs/templates-ref.rst @@ -24,16 +24,16 @@ Variables, macros and filters can be used in templates (see the :ref:`concepts:j Asset-triggered DAGs -------------------- -Asset-triggered DAGs in Apache Airflow 3 differ from time-based DAGs in the +Asset-triggered Dags in Apache Airflow 3 differ from time-based Dags in the template context they provide. -Asset-triggered DAGs do not have a logical date, and therefore do not provide +Asset-triggered Dags do not have a logical date, and therefore do not provide time-based context variables such as ``logical_date``, ``ds``, ``ds_nodash``, or values derived from them. -For asset-triggered DAGs, information related to the triggering run can be +For asset-triggered Dags, information related to the triggering run can be accessed via ``dag_run``. For example, ``dag_run.run_id`` can be used to -uniquely identify a DAG run triggered by an asset event. +uniquely identify a Dag run triggered by an asset event. .. versionadded:: 3.0.0