about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-07-31 16:16:33 -0500
committerFrederick Muriuki Muriithi2025-07-31 16:16:33 -0500
commit065309242ab1c7bd378faa49f25545bad4761d89 (patch)
treebe6841a0cf2bba9a22ba3ba43fec0c827ffa138e
parentf275b3ab6172922cef97822804e54e6513937c2a (diff)
downloadgn-auth-065309242ab1c7bd378faa49f25545bad4761d89.tar.gz
Check for data inconsistency.
-rw-r--r--gn_auth/auth/authorisation/resources/groups/models.py10
1 files changed, 8 insertions, 2 deletions
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(