From 52b935fc216ef9abc0e71142b8a0ea1242ef0201 Mon Sep 17 00:00:00 2001 From: Augustin-FL Date: Tue, 30 May 2023 16:31:03 +0200 Subject: [PATCH] comments can be sometimes None in addition to [] --- web/views/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/views/helpers.py b/web/views/helpers.py index 7fc51a9c..30a026db 100755 --- a/web/views/helpers.py +++ b/web/views/helpers.py @@ -16,7 +16,7 @@ def remove_field(instance, field): try: del instance[field] - except KeyError: + except (KeyError, TypeError): pass @@ -50,7 +50,7 @@ def clean_analyses(analyses): def enrich_comments(obj): - if 'comments' in obj: + if 'comments' in obj and isinstance(obj, list): for comment in obj['comments']: if 'analyst' in comment: analyst = store.users.find_one({'_id': comment['analyst']})