From 535d869ddcd8caaa2894b24aa2de75ee89844a7f Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 24 Mar 2023 11:03:27 +0100 Subject: [PATCH] Fix error handling --- src/attachments/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/attachments/models.py b/src/attachments/models.py index 2ea9813..f8be2bd 100644 --- a/src/attachments/models.py +++ b/src/attachments/models.py @@ -100,8 +100,8 @@ class Attachment(models.Model): ) res = response.json() - if len(res) == 0: - logger.error("Shortpixel response is empty: %s", res) + if len(res) == 0 or not isinstance(res, list): + logger.error("Shortpixel response is not a non-empty list: %s", res) return super().save(*args, **kwargs) res_data = res[0]