Fix error handling

This commit is contained in:
Gabriel Augendre 2023-03-24 11:03:27 +01:00
parent 0e1d84733e
commit 535d869ddc

View file

@ -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]