Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate conf from Task Context #44968

Merged
merged 2 commits into from
Dec 17, 2024
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: 1 addition & 0 deletions airflow/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ class Context(MutableMapping[str, Any]):
"tomorrow_ds_nodash": [],
"yesterday_ds": [],
"yesterday_ds_nodash": [],
"conf": [],
}

def __init__(self, context: MutableMapping[str, Any] | None = None, **kwargs: Any) -> None:
Expand Down
4 changes: 2 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 Expand Up @@ -133,6 +131,8 @@ Deprecated Variable Description
you may be able to use ``prev_data_interval_start_success`` instead if
the timetable/schedule you use for the DAG defines ``data_interval_start``
compatible with the legacy ``execution_date``.
``{{ conf }}`` The full configuration object representing the content of your
``airflow.cfg``. See :mod:`airflow.configuration.conf`.
===================================== ==========================================================================

Note that you can access the object's attributes and methods with simple
Expand Down
1 change: 1 addition & 0 deletions newsfragments/44968.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``conf`` variable, which provided access to the full Airflow configuration (``airflow.cfg``), has been deprecated and will be removed in Airflow 3 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.