From 065309242ab1c7bd378faa49f25545bad4761d89 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 31 Jul 2025 16:16:33 -0500 Subject: Check for data inconsistency. --- gn_auth/auth/authorisation/resources/groups/models.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gn_auth/auth/authorisation/resources/groups/models.py') diff --git a/gn_auth/auth/authorisation/resources/groups/models.py b/gn_auth/auth/authorisation/resources/groups/models.py index d0aaef8..3189302 100644 --- a/gn_auth/auth/authorisation/resources/groups/models.py +++ b/gn_auth/auth/authorisation/resources/groups/models.py @@ -337,8 +337,14 @@ def resource_from_group(conn: db.DbConnection, the_group: Group) -> Resource: "WHERE group_resources.group_id=?", (str(the_group.group_id),)) results = tuple(resource_from_dbrow(row) for row in cursor.fetchall()) - assert len(results) == 1, "Expected a single group resource." - return results[0] + match len(results): + case 0: + raise InconsistencyError("The group lacks a wrapper resource.") + case 1: + return results[0] + case _: + raise InconsistencyError( + "The group has more than one wrapper resource.") def remove_user_from_group( -- cgit 1.4.1