[FIX] base_import: prevent trackback while upload unidentified image URL

This issue occurs when a customer imports or uploads a file, and that file
 contains an image that is attached to the URL as text or HTML. then,
 The error would be generated.

  Step to Produce:-
 - import CSV file (Ex.'product.product' model)
    > that CSV file must have one URL Image(In that URL has content of text or
      Html form)
 - Click On the 'Test' Button.

  Applying these changes will resolve this issue.

  sentry:-4046190590

closes odoo/odoo#137611

X-original-commit: acbb5af7ee96cdc579850427bc2bca6d7bf184e4
Signed-off-by: Achraf Ben Azzouz (abz) <abz@odoo.com>
This commit is contained in:
Sanket Brahmbhatt
2023-10-05 05:16:52 +00:00
parent 3f8a891eac
commit d615c5bfaa
2 changed files with 8 additions and 9 deletions
+7 -8
View File
@@ -1263,14 +1263,13 @@ class Import(models.TransientModel):
return base64.b64encode(content)
except Exception as e:
_logger.exception(e)
raise ImportValidationError(
_(
"Could not retrieve URL: %(url)s [%(field_name)s: L%(line_number)d]: %(error)s",
url=url, field_name=field, line_number=line_number + 1, error=e
),
field=field
)
_logger.warning(e, exc_info=True)
raise ValueError(_("Could not retrieve URL: %(url)s [%(field_name)s: L%(line_number)d]: %(error)s") % {
'url': url,
'field_name': field,
'line_number': line_number + 1,
'error': e
})
def execute_import(self, fields, columns, options, dryrun=False):
""" Actual execution of the import
+1 -1
View File
@@ -517,7 +517,7 @@ class Image(models.AbstractModel):
# force a complete load of the image data to validate it
image.load()
except Exception:
logger.exception("Failed to load remote image %r", url)
logger.warning("Failed to load remote image %r", url, exc_info=True)
return None
# don't use original data in case weird stuff was smuggled in, with