This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new e34b725b382 Raise a warning instead of an error if extra teams are 
defined in the auth manager (#68935)
e34b725b382 is described below

commit e34b725b382ec0a23224396a88527a6818d86913
Author: stephen-bracken <[email protected]>
AuthorDate: Thu Jun 25 14:47:20 2026 +0100

    Raise a warning instead of an error if extra teams are defined in the auth 
manager (#68935)
---
 .../api_fastapi/auth/managers/base_auth_manager.py | 12 ++++++++++--
 .../auth/managers/test_base_auth_manager.py        | 22 ++++++++++++++++------
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git 
a/airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py 
b/airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py
index 4ba08e5b447..d587ec7a680 100644
--- a/airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py
+++ b/airflow-core/src/airflow/api_fastapi/auth/managers/base_auth_manager.py
@@ -127,8 +127,16 @@ class BaseAuthManager(Generic[T], LoggingMixin, 
metaclass=ABCMeta):
             db_teams = Team.get_all_team_names()
 
             if not db_teams.issuperset(am_teams):
-                raise ValueError(
-                    f"Teams defined in the auth manager ({am_teams}) are not 
present in the database ({db_teams})."
+                warnings.warn(
+                    f"Teams defined in the auth manager are not present in the 
database ({am_teams.difference(db_teams)}).",
+                    UserWarning,
+                    stacklevel=2,
+                )
+            if not am_teams.issuperset(db_teams):
+                warnings.warn(
+                    f"Teams defined in the database are not present in the 
auth manager ({db_teams.difference(am_teams)}).",
+                    UserWarning,
+                    stacklevel=2,
                 )
 
     @abstractmethod
diff --git 
a/airflow-core/tests/unit/api_fastapi/auth/managers/test_base_auth_manager.py 
b/airflow-core/tests/unit/api_fastapi/auth/managers/test_base_auth_manager.py
index 18898bddd2d..348bce778ec 100644
--- 
a/airflow-core/tests/unit/api_fastapi/auth/managers/test_base_auth_manager.py
+++ 
b/airflow-core/tests/unit/api_fastapi/auth/managers/test_base_auth_manager.py
@@ -161,10 +161,11 @@ class TestBaseAuthManager:
     @pytest.mark.parametrize(
         ("auth_manager_teams", "db_teams", "expected"),
         [
-            ({"teamA", "teamB"}, {"teamA", "teamB"}, True),
-            ({"teamA", "teamB"}, {"teamA", "teamB", "teamC"}, True),
-            (set(), set(), True),
-            ({"teamA", "teamB"}, {"teamA", "teamC"}, False),
+            pytest.param({"teamA", "teamB"}, {"teamA", "teamB"}, "same", 
id="same teams"),
+            pytest.param({"teamA", "teamB"}, {"teamA", "teamB", "teamC"}, 
"extra_db", id="extra teams db"),
+            pytest.param(set(), set(), "same", id="no teams"),
+            pytest.param({"teamA", "teamB"}, {"teamA"}, "extra_auth", 
id="extra teams auth"),
+            pytest.param({"teamA", "teamB"}, {"teamA", "teamC"}, "extra_both", 
id="extra teams both"),
         ],
     )
     @patch.object(Team, "get_all_team_names")
@@ -175,10 +176,19 @@ class TestBaseAuthManager:
         mock_get_teams.return_value = auth_manager_teams
         mock_get_all_team_names.return_value = db_teams
 
-        if expected:
+        if expected == "same":
             assert auth_manager.init() is None
+        elif expected == "extra_auth":
+            with pytest.warns(UserWarning, match="Teams defined in the auth 
manager"):
+                auth_manager.init()
+        elif expected == "extra_db":
+            with pytest.warns(UserWarning, match="Teams defined in the 
database"):
+                auth_manager.init()
         else:
-            with pytest.raises(ValueError, match="Teams defined in the auth 
manager"):
+            with (
+                pytest.warns(UserWarning, match="Teams defined in the 
database"),
+                pytest.warns(UserWarning, match="Teams defined in the auth 
manager"),
+            ):
                 auth_manager.init()
 
     def test_get_cli_commands_return_empty_list(self, auth_manager):

Reply via email to