diff --git a/githubapp/keycloak.py b/githubapp/keycloak.py index f397b7c..8dac12e 100644 --- a/githubapp/keycloak.py +++ b/githubapp/keycloak.py @@ -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"] + if not group: + raise Exception(f"Cannot find group {group_name} in Keycloak") + else: + return group[0]["id"] def get_members(client: KeycloakAdmin = None, group_id: str = None): """