Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Errors from thumbnailing due to bad format give a 500 #3763

Closed
richvdh opened this issue Aug 28, 2018 · 2 comments · Fixed by #8236
Closed

Errors from thumbnailing due to bad format give a 500 #3763

richvdh opened this issue Aug 28, 2018 · 2 comments · Fixed by #8236
Labels
A-Media-Repository Uploading, downloading images and video, thumbnailing z-minor (Deprecated Label) z-p2 (Deprecated Label)

Comments

@richvdh
Copy link
Member

richvdh commented Aug 28, 2018

We should either accept it regardless (with no thumbnail) or give a 400. Example:

2018-08-28 09:36:53,588 - synapse.http.server - 101 - ERROR - POST-10386 - Failed handle request via <function _async_render_POST at 0x7f0426db1cf8>: <XForwardedForRequest at 0x7f03ecea0440 method='POST' uri='/_matrix/media/v1/upload?filename=1535448124087775917601.jpg' clientproto='HTTP/1.1' site=8085>: Traceback (
most recent call last):
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1475, in gotResult
    _inlineCallbacks(r, g, status)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
--- <exception caught here> ---
  File "synapse/http/server.py", line 81, in wrapped_request_handler
    
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "synapse/rest/media/v1/upload_resource.py", line 95, in _async_render_POST
    
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "synapse/rest/media/v1/media_repository.py", line 174, in create_content
    
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "synapse/rest/media/v1/media_repository.py", line 626, in _generate_thumbnails
    
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 250, in inContext
    result = inContext.theWork()
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "synapse/rest/media/v1/thumbnailer.py", line 60, in scale
    
  File "synapse/rest/media/v1/thumbnailer.py", line 96, in _encode_image
    
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/PIL/Image.py", line 1950, in save
    save_handler(self, fp, filename)
  File "/home/matrix/.synapse/local/lib/python2.7/site-packages/PIL/JpegImagePlugin.py", line 623, in _save
    raise IOError("cannot write mode %s as JPEG" % im.mode)
exceptions.IOError: cannot write mode RGBA as JPEG
@bmarty
Copy link

bmarty commented Aug 28, 2018

May explain (the source cause of) error reported here: element-hq/riot-android#1120

@martindale
Copy link

martindale commented May 25, 2020

Bumped into this as well. Found this in homeserver.log:

2020-05-25 05:09:52,559 - synapse.http.server - 110 - ERROR - POST-8374845 - Failed handle request via 'UploadResource': <XForwardedForRequest at 0x7f78dff7d6d8 method='POST' uri='/_matrix/media/r0/upload?filename=the-lockbox.png&access_token=<redacted>' clientproto='HTTP/1.1' site=8008>
Traceback (most recent call last):
  File "/opt/synapse/env3/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/synapse/env3/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/synapse/env3/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
StopIteration: True

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/synapse/env3/lib/python3.6/site-packages/synapse/http/server.py", line 78, in wrapped_request_handler
    await h(self, request)
  File "/opt/synapse/env3/lib/python3.6/site-packages/synapse/rest/media/v1/upload_resource.py", line 86, in _async_render_POST
    media_type, upload_name, request.content, content_length, requester.user
OSError: cannot identify image file '/opt/synapse/media_store/local_content/GX/It/SbzKpmQPwIKpuaglWPOS'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Media-Repository Uploading, downloading images and video, thumbnailing z-minor (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants