Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(backend): handle role prefix in GetUsersByRoleInIAMPolicy (#18932)

p0nyf323daa0da85
diff --git a/backend/utils/member.go b/backend/utils/member.go
index d88a5bed1c..f04c249136 100644
--- a/backend/utils/member.go
+++ b/backend/utils/member.go
@@ -32,8 +32,12 @@ func FormatGroupName(group *store.GroupMessage) string {
}
// GetUsersByRoleInIAMPolicy gets users in the iam policy.
+// The role can be either with or without the "roles/" prefix.
func GetUsersByRoleInIAMPolicy(ctx context.Context, stores *store.Store, role string, policies ...*storepb.IamPolicy) []*store.UserMessage {
- roleFullName := common.FormatRole(role)
+ roleFullName := role
+ if !strings.HasPrefix(role, common.RolePrefix) {
+ roleFullName = common.FormatRole(role)
+ }
var users []*store.UserMessage
seen := map[string]bool{}