Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix roles (#38501)

Joshen Lim8c6c3eb0d2be
diff --git a/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.utils.ts b/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.utils.ts
index 7b2cb3e2d27..bc3dfb71627 100644
--- a/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.utils.ts
+++ b/apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.utils.ts
@@ -42,9 +42,16 @@ export const formatMemberRoleToProjectRoleConfiguration = (
})
.filter(Boolean)
.flat()
- .filter(
- (p) => p !== undefined && 'baseRoleId' in p && p.ref !== undefined
- ) as ProjectRoleConfiguration[]
+ .filter((p) => {
+ // [Joshen] Validate only for project scoped roles
+ // This filters out project scoped roles for projects that the user doesn't have access to
+ // (e.g if the project was deleted)
+ if ('baseRoleId' in p!) {
+ return p.ref !== undefined
+ } else {
+ return p
+ }
+ }) as ProjectRoleConfiguration[]
return roleConfiguration
}