From 39a9bcf7bf52a5d5e0159bc1892bc0985834097a Mon Sep 17 00:00:00 2001 From: ccoliu <52516787+ccoliu@users.noreply.github.com> Date: Thu, 20 Aug 2026 23:08:55 +0800 Subject: [PATCH] [v3-3-test] Fix Variable.set rewriting team_name of existing variables (#71823) (cherry picked from commit 132ec4f59b8bc3b3795113ac6e5fc3d0f8d697a2) Co-authored-by: ccoliu <52516787+ccoliu@users.noreply.github.com> --- 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..0bc32373a305d 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()