From 8d563f6ca0151059571ab444e390da1c5247157d Mon Sep 17 00:00:00 2001 From: ccoliu Date: Wed, 19 Aug 2026 16:19:48 +0800 Subject: [PATCH 1/2] Fix Variable.set rewriting team_name of existing variables (#71810) --- airflow-core/src/airflow/models/variable.py | 1 - airflow-core/tests/unit/models/test_variable.py | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/airflow-core/src/airflow/models/variable.py b/airflow-core/src/airflow/models/variable.py index c366a2482b1ec..9493cab60aa38 100644 --- a/airflow-core/src/airflow/models/variable.py +++ b/airflow-core/src/airflow/models/variable.py @@ -287,7 +287,6 @@ def set( val=val, description=description, is_encrypted=is_encrypted, - team_name=team_name, ) stmt = build_upsert_stmt( get_dialect_name(session), Variable, ["key"], upsert_values, update_fields diff --git a/airflow-core/tests/unit/models/test_variable.py b/airflow-core/tests/unit/models/test_variable.py index 001a29a7c0c1e..e89e7925edcbb 100644 --- a/airflow-core/tests/unit/models/test_variable.py +++ b/airflow-core/tests/unit/models/test_variable.py @@ -369,6 +369,14 @@ def test_masking_from_db(self, session): finally: session.rollback() + @conf_vars({("core", "multi_team"): "True"}) + def test_variable_set_does_not_change_team_name_on_update(self, testing_team, session): + Variable.set(key="k", value="v1", session=session) + + Variable.set(key="k", value="v2", team_name=testing_team.name, session=session) + + assert Variable.get("k") == "v2" + @mock.patch("airflow.models.variable.ensure_secrets_loaded") def test_caching_caches(self, mock_ensure_secrets: mock.Mock): mock_backend = mock.Mock() From 29d37c64a28383dcb262061e6643ea944c3a67c9 Mon Sep 17 00:00:00 2001 From: ccoliu Date: Wed, 19 Aug 2026 23:24:08 +0800 Subject: [PATCH 2/2] Fix trailing whitespace in test_variable.py --- airflow-core/tests/unit/models/test_variable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow-core/tests/unit/models/test_variable.py b/airflow-core/tests/unit/models/test_variable.py index e89e7925edcbb..0bc32373a305d 100644 --- a/airflow-core/tests/unit/models/test_variable.py +++ b/airflow-core/tests/unit/models/test_variable.py @@ -374,7 +374,7 @@ def test_variable_set_does_not_change_team_name_on_update(self, testing_team, se Variable.set(key="k", value="v1", session=session) Variable.set(key="k", value="v2", team_name=testing_team.name, session=session) - + assert Variable.get("k") == "v2" @mock.patch("airflow.models.variable.ensure_secrets_loaded")