From ee5509b1964605c904c43d66798fb34363703b2f Mon Sep 17 00:00:00 2001 From: Maxwell-Lindsey Date: Mon, 26 Feb 2024 19:49:08 -0600 Subject: [PATCH] improved null checking and handling to prevent iterating over none --- ai_ta_backend/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ai_ta_backend/main.py b/ai_ta_backend/main.py index 79ff72d8..d0dd0e0b 100644 --- a/ai_ta_backend/main.py +++ b/ai_ta_backend/main.py @@ -739,7 +739,7 @@ def appendDocumentToGroup(): doc_group = data['doc_group'] document_data = data.get('document', {}) - document_data['doc_groups'] = [group for group in document_data.get('doc_groups', []) if group is not None] + document_data['doc_groups'] = [group for group in (document_data.get('doc_groups') or []) if group is not None] try: document = MaterialDocument(**document_data) @@ -766,7 +766,7 @@ def removeDocumentFromGroup(): doc_group = data['doc_group'] document_data = data.get('document', {}) - document_data['doc_groups'] = [group for group in document_data.get('doc_groups', []) if group is not None] + document_data['doc_groups'] = [group for group in (document_data.get('doc_groups') or []) if group is not None] try: document = MaterialDocument(**document_data)