This is an automated email from the ASF dual-hosted git repository.
kaxilnaik pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v2-10-test by this push:
new 0ad24cf39e6 Deprecate `conf` from Task Context (#44993)
0ad24cf39e6 is described below
commit 0ad24cf39e690a434ddf198bebd61c54def5419d
Author: Kaxil Naik <[email protected]>
AuthorDate: Wed Dec 18 01:02:21 2024 +0530
Deprecate `conf` from Task Context (#44993)
This was initially added in response to
https://github.com/apache/airflow/issues/168. However, we now have `ti.log_url`
that is used for that; example usages:
https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/airflow/models/taskinstance.py#L1362
https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/providers/src/airflow/providers/smtp/notifications/templates/email.html#L28
https://github.com/apache/airflow/blob/dcd41f60f1c9b5583b49bfb49b6d85c640a2892c/docs/apache-airflow/howto/email-config.rst?plain=1#L76
So, to simplify what we need to pass from API server to the Task SDK in
preparation for Airflow 3, I want to simplify and remove things that aren't
needed. In this case, this is good so we don't pass/expore secrets unnecesarily
via `conf`. This is removed in Airflow 3 and deprecated in 2.10.x/2.11
Mailing list Thread:
https://lists.apache.org/thread/2n0l8y2oyq4442p0lsnmbbcl6rmbj3k7
---
airflow/utils/context.py | 1 +
docs/apache-airflow/templates-ref.rst | 4 ++--
newsfragments/44968.misc.rst | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/airflow/utils/context.py b/airflow/utils/context.py
index 9dddcc3f16c..85834cb3dab 100644
--- a/airflow/utils/context.py
+++ b/airflow/utils/context.py
@@ -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:
diff --git a/docs/apache-airflow/templates-ref.rst
b/docs/apache-airflow/templates-ref.rst
index 05d4b10accc..c00db17a6ae 100644
--- a/docs/apache-airflow/templates-ref.rst
+++ b/docs/apache-airflow/templates-ref.rst
@@ -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.
@@ -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
diff --git a/newsfragments/44968.misc.rst b/newsfragments/44968.misc.rst
new file mode 100644
index 00000000000..160ccd60855
--- /dev/null
+++ b/newsfragments/44968.misc.rst
@@ -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 [...]