From 7c5aef033d76805002672fc240439bc469600a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 12 May 2017 13:35:50 +0200 Subject: [PATCH] Some more checks on p.a.project.utils.get_admin_group_id() --- pillar/api/projects/utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pillar/api/projects/utils.py b/pillar/api/projects/utils.py index 7d18a5a9..e6c2a981 100644 --- a/pillar/api/projects/utils.py +++ b/pillar/api/projects/utils.py @@ -28,8 +28,13 @@ def project_total_file_size(project_id): def get_admin_group_id(project_id: ObjectId) -> ObjectId: + assert isinstance(project_id, ObjectId) + project = current_app.db('projects').find_one({'_id': project_id}, {'permissions': 1}) + if not project: + raise ValueError(f'Project {project_id} does not exist.') + # TODO: search through all groups to find the one with the project ID as its name, # or identify "the admin group" in a different way (for example the group with DELETE rights). try: