From cc54a136f14dd434667776e30ee308ef7b65f6f9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Sat, 29 Jun 2024 14:55:48 -0400 Subject: [PATCH] Fix server error when passing null collection types. --- etebase_server/fastapi/routers/collection.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etebase_server/fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py index e5990b6..bb01474 100644 --- a/etebase_server/fastapi/routers/collection.py +++ b/etebase_server/fastapi/routers/collection.py @@ -342,7 +342,10 @@ def _create(data: CollectionIn, user: UserType): # TODO process_revisions_for_item(main_item, data.item.content) - collection_type_obj, _ = models.CollectionType.objects.get_or_create(uid=data.collectionType, owner=user) + try: + collection_type_obj, _ = models.CollectionType.objects.get_or_create(uid=data.collectionType, owner=user) + except IntegrityError: + raise ValidationError("bad_collection_type", "collectionType is null") models.CollectionMember( collection=instance,