From bd3bccb4580732e5a0a4f2f2917286eb0a433227 Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Wed, 13 Mar 2024 12:51:32 +0530 Subject: [PATCH] [FIX] mass_mailing: handle UnidentifiedImageError while convert image to url Currently, a logger exception is generated when the user tries to upload any image as document in the mass mail. This is because an UnidentifiedImageError occurs when the user uploads an image file as a document and code [1] tries to open it with Image. This commit adds code that handles an UnidentifiedImageError, and it adds the message in the log for an invalid image file. [1] - https://github.com/odoo/odoo/blob/029b84f3c061f819bacb9a4818504cced4adeb1c/addons/mass_mailing/models/mailing.py#L1405 sentry-4311184876 closes odoo/odoo#159653 X-original-commit: e4b7ec191fc81ec806736758f273e20b6260bbeb Signed-off-by: Thibault Delavallee (tde) Signed-off-by: ANSARI MAHAMADASIF (maan) --- addons/mass_mailing/models/mailing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/mass_mailing/models/mailing.py b/addons/mass_mailing/models/mailing.py index 870868c5757..f02234e7c8a 100644 --- a/addons/mass_mailing/models/mailing.py +++ b/addons/mass_mailing/models/mailing.py @@ -1440,6 +1440,9 @@ class MassMailing(models.Model): ) return content + except UnidentifiedImageError: + _logger.warning('This file could not be decoded as an image file.', exc_info=True) + raise except Exception as e: _logger.exception(e) raise ImportValidationError(_("Could not retrieve URL: %s", url)) from e