Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,6 @@ def get_triggering_events() -> dict[str, list[AssetEvent]]:
# * KNOWN_CONTEXT_KEYS in airflow/utils/context.py
# * Table in docs/apache-airflow/templates-ref.rst
context: dict[str, Any] = {
"conf": conf,
"dag": dag,
"dag_run": dag_run,
"data_interval_end": timezone.coerce_datetime(data_interval.end),
Expand Down
1 change: 0 additions & 1 deletion airflow/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
# * Context in airflow/utils/context.pyi.
# * Table in docs/apache-airflow/templates-ref.rst
KNOWN_CONTEXT_KEYS: set[str] = {
"conf",
"conn",
"dag",
"dag_run",
Expand Down
2 changes: 0 additions & 2 deletions airflow/utils/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ from typing import Any, overload
from pendulum import DateTime
from sqlalchemy.orm import Session

from airflow.configuration import AirflowConfigParser
from airflow.models.asset import AssetEvent
from airflow.models.baseoperator import BaseOperator
from airflow.models.dag import DAG
Expand Down Expand Up @@ -100,7 +99,6 @@ class InletEventsAccessors(Mapping[Asset | AssetAlias, InletEventsAccessor]):
# * KNOWN_CONTEXT_KEYS in airflow/utils/context.py
# * Table in docs/apache-airflow/templates-ref.rst
class Context(TypedDict, total=False):
conf: AirflowConfigParser
conn: Any
dag: DAG
dag_run: DagRun | DagRunPydantic
Expand Down
2 changes: 0 additions & 2 deletions docs/apache-airflow/templates-ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ Variable Type Description
``{{ 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
| ``{dag_id}__{task_id}__{ds_nodash}``.
``{{ conf }}`` AirflowConfigParser | The full configuration object representing the content of your
| ``airflow.cfg``. See :mod:`airflow.configuration.conf`.
``{{ 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.
Expand Down
38 changes: 38 additions & 0 deletions newsfragments/44820.significant.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Removed ``conf`` from the Task template context

The ``conf`` variable, which provided access to the full Airflow configuration (``airflow.cfg``), has been
removed from the Task (Jinja2) template context for security and simplicity. If you
need specific configuration values in your tasks, retrieve them explicitly in your DAG or task code
using the ``airflow.configuration.conf`` module.

For users retrieving the webserver URL (e.g., to include log links in task or callbacks), one of the
most common use-case, use the ``ti.log_url`` property available in the ``TaskInstance`` context instead.

Example:

.. code-block:: python

PythonOperator(
task_id="my_task",
python_callable=my_task_callable,
on_failure_callback=SmtpNotifier(
from_email="example@example.com",
to="example@example.com",
subject="Task {{ ti.task_id }} failed",
html_content="Task <b>{{ ti.task_id }}</b> failed. Log URL: {{ ti.log_url }}",
),
)

* Types of change

* [x] DAG changes
* [ ] Config changes
* [ ] API changes
* [ ] CLI changes
* [ ] Behaviour changes
* [ ] Plugin changes
* [ ] Dependency changes

* Migration rules needed

* Remove context key ``conf``