Skip to content

Commit

Permalink
Keycloak: raise Exception if group isn't found
Browse files Browse the repository at this point in the history
  • Loading branch information
NotActuallyTerry committed May 28, 2024
1 parent 4554b7a commit 7bc7723
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions githubapp/keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ def get_group_id(client: KeycloakAdmin = None):
:return: The group's UUID in Keycloak
"""
group = client.get_groups(query={"search": group_name})
group = client.get_groups(query={"search": group_name, "briefRepresentation": "true", "exact": "true"})
return group[0]["id"]
try:
group_id = group[0]["id"]
except IndexError:
raise Exception(f"Cannot find group {group_name} in Keycloak")
return group_id

def get_members(client: KeycloakAdmin = None, group_id: str = None):
"""
Expand Down

0 comments on commit 7bc7723

Please sign in to comment.