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 0f2ec8a3c32 Fix FAB userinfo page breaking after viewing a user 
(#76473)
0f2ec8a3c32 is described below

commit 0f2ec8a3c3287348b7bcd77baab4fb2e8c0e678e
Author: wbg <[email protected]>
AuthorDate: Wed Nov 18 01:31:59 2026 +0100

    Fix FAB userinfo page breaking after viewing a user (#76473)
    
    MultiResourceUserMixin.show() pops "userinfoedit" and "resetmypassword"
    from the actions dict passed to the show widget. FAB hands the view's
    shared self.actions through, so once an admin opens a user's show page,
    /users/userinfo/ and "Reset my password" fail with AttributeError on
    that worker until the api-server restarts.
---
 .../providers/fab/auth_manager/views/user.py       | 10 ++++--
 .../tests/unit/fab/auth_manager/views/test_user.py | 36 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/providers/fab/src/airflow/providers/fab/auth_manager/views/user.py 
b/providers/fab/src/airflow/providers/fab/auth_manager/views/user.py
index 4c2b99f5f6a..4f220d310bc 100644
--- a/providers/fab/src/airflow/providers/fab/auth_manager/views/user.py
+++ b/providers/fab/src/airflow/providers/fab/auth_manager/views/user.py
@@ -78,8 +78,14 @@ class MultiResourceUserMixin:
     def show(self, pk):
         pk = self._deserialize_pk_if_composite(pk)
         widgets = self._show(pk)
-        widgets["show"].template_args["actions"].pop("userinfoedit", None)
-        widgets["show"].template_args["actions"].pop("resetmypassword", None)
+        # ``template_args["actions"]`` is the view's shared ``self.actions`` 
dict, never mutate it.
+        # userinfo and the action endpoints read from it too.
+        show_args = widgets["show"].template_args
+        show_args["actions"] = {
+            name: action
+            for name, action in show_args["actions"].items()
+            if name not in ("userinfoedit", "resetmypassword")
+        }
         return self.render_template(
             self.show_template,
             pk=pk,
diff --git a/providers/fab/tests/unit/fab/auth_manager/views/test_user.py 
b/providers/fab/tests/unit/fab/auth_manager/views/test_user.py
index c2f024cd69a..f81b67d5268 100644
--- a/providers/fab/tests/unit/fab/auth_manager/views/test_user.py
+++ b/providers/fab/tests/unit/fab/auth_manager/views/test_user.py
@@ -57,6 +57,23 @@ def user_user_reader(fab_app):
         delete_user(fab_app, "user_user")
 
 
[email protected](scope="module")
+def user_show_and_profile(fab_app):
+    with fab_app.app_context():
+        yield create_user(
+            fab_app,
+            username="user_show_and_profile",
+            role_name="role_show_and_profile",
+            permissions=[
+                (permissions.ACTION_CAN_READ, permissions.RESOURCE_USER),
+                (permissions.ACTION_CAN_READ, permissions.RESOURCE_MY_PROFILE),
+                (permissions.ACTION_CAN_READ, permissions.RESOURCE_WEBSITE),
+            ],
+        )
+
+        delete_user(fab_app, "user_show_and_profile")
+
+
 @pytest.fixture
 def client_user_reader(fab_app, user_user_reader):
     fab_app.config["WTF_CSRF_ENABLED"] = False
@@ -74,3 +91,22 @@ class TestUserView:
 
         _assert_dataset_deprecation_warning(recwarn)
         assert resp.status_code == 200
+
+    def test_show_user_keeps_self_service_actions_on_userinfo(self, fab_app, 
user_show_and_profile):
+        fab_app.config["WTF_CSRF_ENABLED"] = False
+        client = client_with_login(
+            fab_app,
+            username="user_show_and_profile",
+            password="user_show_and_profile",
+        )
+
+        resp = client.get(f"/users/show/{user_show_and_profile.id}")
+        assert resp.status_code == 200
+        assert "/action/resetmypassword/" not in resp.text
+        assert "/action/userinfoedit/" not in resp.text
+
+        # show() must not remove the actions from the view's shared dict, 
userinfo needs them
+        resp = client.get("/users/userinfo/")
+        assert resp.status_code == 200
+        assert "/action/resetmypassword/" in resp.text
+        assert "/action/userinfoedit/" in resp.text

Reply via email to