diff options
author | Frederick Muriuki Muriithi | 2025-07-31 16:16:33 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-07-31 16:16:33 -0500 |
commit | 065309242ab1c7bd378faa49f25545bad4761d89 (patch) | |
tree | be6841a0cf2bba9a22ba3ba43fec0c827ffa138e | |
parent | f275b3ab6172922cef97822804e54e6513937c2a (diff) | |
download | gn-auth-065309242ab1c7bd378faa49f25545bad4761d89.tar.gz |
Check for data inconsistency.
-rw-r--r-- | gn_auth/auth/authorisation/resources/groups/models.py | 10 |
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( |