From 04783547462a9a9c30b2a62e2beee08409a06afc Mon Sep 17 00:00:00 2001 From: Nizamudeen A Date: Tue, 27 Feb 2024 12:48:56 +0530 Subject: [PATCH] mgr/dashboard: fix roles page for roles without policies If there is no permission policies attached to a role, it fails the UI with an exception. Fixes: https://tracker.ceph.com/issues/64588 Signed-off-by: Nizamudeen A (cherry picked from commit 5f3f31921c9f3ed909a94f287bfd4cc3f0987649) --- .../app/shared/datatable/crud-table/crud-table.component.ts | 2 +- src/pybind/mgr/dashboard/services/rgw_client.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts index fa3a9d76a0b..2d1f520bac6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/crud-table/crud-table.component.ts @@ -147,7 +147,7 @@ export class CRUDTableComponent implements OnInit { setExpandedRow(event: any) { for (let i = 0; i < this.meta.detail_columns.length; i++) { let column = this.meta.detail_columns[i]; - let columnDetail = event[column]; + let columnDetail = event?.[column]; this.expandedRow[column] = this.formatColumnDetails(columnDetail); } } diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py index 2d3226bab3e..7db28506ddc 100644 --- a/src/pybind/mgr/dashboard/services/rgw_client.py +++ b/src/pybind/mgr/dashboard/services/rgw_client.py @@ -806,6 +806,9 @@ class RgwClient(RestClient): logger.warning('Error listing roles with code %d: %s', code, err) return [] + for role in roles: + if 'PermissionPolicies' not in role: + role['PermissionPolicies'] = [] return roles def create_role(self, role_name: str, role_path: str, role_assume_policy_doc: str) -> None: -- 2.39.5