Importing admin chart as gamma user changes ownership #29769
Replies: 1 comment 1 reply
-
Hey @joezeon! I'm here to assist you with any bugs, questions, or contributions you may have. Let's work on resolving this issue together. Yes, it appears to be a bug that a Gamma role user cannot change the ownership of a chart owned by the Superset Admin, even though the ownership can be changed after exporting and re-importing the chart. Supporting evidence from the provided document: def test_import_new_dashboard_slice_reset_ownership(self):
admin_user = security_manager.find_user(username="admin")
self.assertTrue(admin_user)
gamma_user = security_manager.find_user(username="gamma")
self.assertTrue(gamma_user)
g.user = gamma_user
dash_with_1_slice = self._create_dashboard_for_import(id_=10200)
# set another user as an owner of importing dashboard
dash_with_1_slice.created_by = admin_user
dash_with_1_slice.changed_by = admin_user
dash_with_1_slice.owners = [admin_user]
imported_dash_id = import_dashboard(dash_with_1_slice)
imported_dash = self.get_dash(imported_dash_id)
self.assertEqual(imported_dash.created_by, gamma_user)
self.assertEqual(imported_dash.changed_by, gamma_user)
self.assertEqual(imported_dash.owners, [gamma_user])
imported_slc = imported_dash.slices[0]
self.assertEqual(imported_slc.created_by, gamma_user)
self.assertEqual(imported_slc.changed_by, gamma_user)
self.assertEqual(imported_slc.owners, [gamma_user]) Additionally, the new document provides further context on ownership and permissions: def test_update_chart_new_owner_not_admin(self):
"""
Chart API: Test update set new owner implicitly adds logged in owner
"""
gamma = self.get_user("gamma_no_csv")
alpha = self.get_user("alpha")
chart_id = self.insert_chart("title", [gamma.id], 1).id
chart_data = {
"slice_name": (new_name := "title1_changed"),
"owners": [alpha.id],
}
self.login(gamma.username)
uri = f"api/v1/chart/{chart_id}"
rv = self.put_assert_metric(uri, chart_data, "put")
assert rv.status_code == 200
model = db.session.query(Slice).get(chart_id)
assert model.slice_name == new_name
assert alpha in model.owners
assert gamma in model.owners
db.session.delete(model)
db.session.commit() This test case shows that when a Gamma user updates a chart to set a new owner, the logged-in user (Gamma) is implicitly added to the owners list. This behavior further supports the notion that the inability to change ownership directly might be a bug [1][2]. |
Beta Was this translation helpful? Give feedback.
-
Hello All,
Can someone confirm this is a bug? Not sure if Im doing something wrong.
Following charts show when a Gamma role user is logged in. Some are owned by Superset Admin identified by ADMIN.CHART and some owned by the Gamma user.
Logged in as a Gamma user (Gamma role assigned). ADMIN.CHART2 is owned by Superset Admin. If I try to change the ownership and add Gamma User to it, it throws error
Take export of ADMIN.CHART2. Import it back in. Overwrite to Confirm.
Notice ownership now shows both Superset Admin and Gamma User.
Furthermore, I can now remove Superset Admin as the owner and also add other Gamma users as owners.
Shows undefined at first and when refreshed show ownership has changed
Beta Was this translation helpful? Give feedback.
All reactions