The error message is not so informative when an image of an unsupported image format is uploaded in admin:shop.
The following stacktrace was printed in the backend:
2022-08-07 18:53:52,229 ERROR [8/MainThread /usr/local/lib/python3.10/site-packages/flask/app.py:1741]: Exception on /webshop/product_image [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.10/site-packages/flask_cors/extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/work/src/service/internal_service.py", line 69, in view_wrapper
data = f(*args, **kwargs)
File "/work/src/service/entity.py", line 257, in create
return self.to_obj(self._create_internal(data, commit=commit))
File "/work/src/service/entity.py", line 241, in _create_internal
input_data = self.to_model(data)
File "/work/src/shop/product_image_entity.py", line 15, in to_model
image = Image.open(BytesIO(model["data"]))
File "/usr/local/lib/python3.10/site-packages/PIL/Image.py", line 3147, in open
raise UnidentifiedImageError(
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7fd4eda7d530>
The error was apparently that the image was of an unsupported format.
For correctness and completeness, it may be a good idea to phrase the message as something like "unsupported or invalid file format". The message could also be triggered by for example a corrupted or empty file.
The error message is not so informative when an image of an unsupported image format is uploaded in admin:shop.
The following stacktrace was printed in the backend:
The error was apparently that the image was of an unsupported format.