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

Trying to upload long images causes internal server error #5311

Closed
tulir opened this issue Jun 1, 2019 · 1 comment
Closed

Trying to upload long images causes internal server error #5311

tulir opened this issue Jun 1, 2019 · 1 comment
Labels
A-Media-Repository Uploading, downloading images and video, thumbnailing z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@tulir
Copy link
Member

tulir commented Jun 1, 2019

Steps to reproduce

  • Upload an image that is much larger horizontally than vertically (or vice versa), such as the one at https://img.mau.lu/J4Zyj.png
  • Receive internal server error

image

(it also occasionally gets stuck in the uploading stage in riot, but I wasn't able to reproduce that properly)

Version information

  • Version: 0.99.5.2
  • Install method: pip or docker
  • Platform: ubuntu or docker

Traceback

2019-06-01 21:36:39,064 - synapse.http.server - 112 - ERROR - POST-1362 - Failed handle request via 'UploadResource': <XForwardedForRequest at 0x7f9ad6749400 method='POST' uri='/_matrix/media/v1/upload?filename=image.png' clientproto='HTTP/1.1' site=8008>
Traceback (most recent call last):
  File "synapse/git/synapse/http/server.py", line 81, in wrapped_request_handler
    yield h(self, request)
  File "synapse/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "synapse/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "synapse/git/synapse/rest/media/v1/upload_resource.py", line 95, in _async_render_POST
    content_length, requester.user
  File "synapse/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "synapse/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "synapse/git/synapse/rest/media/v1/media_repository.py", line 176, in create_content
    None, media_id, media_id, media_type,
  File "synapse/lib/python3.7/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "synapse/lib/python3.7/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "synapse/git/synapse/rest/media/v1/media_repository.py", line 615, in _generate_thumbnails
    t_width, t_height, t_type,
  File "synapse/lib/python3.7/site-packages/twisted/python/threadpool.py", line 250, in inContext
    result = inContext.theWork()
  File "synapse/lib/python3.7/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
    inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
  File "synapse/lib/python3.7/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "synapse/lib/python3.7/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
  File "synapse/git/synapse/util/logcontext.py", line 636, in g
    return f(*args, **kwargs)
  File "synapse/git/synapse/rest/media/v1/thumbnailer.py", line 94, in scale
    scaled = self.image.resize((width, height), Image.ANTIALIAS)
  File "synapse/lib/python3.7/site-packages/PIL/Image.py", line 1814, in resize
    im = im.resize(size, resample, box)
  File "synapse/lib/python3.7/site-packages/PIL/Image.py", line 1819, in resize
    return self._new(self.im.resize(size, resample, box))
ValueError: height and width must be > 0
@neilisfragile neilisfragile added z-p2 (Deprecated Label) z-bug (Deprecated Label) labels Jun 10, 2019
@richvdh richvdh added the A-Media-Repository Uploading, downloading images and video, thumbnailing label Apr 24, 2020
@squahtx
Copy link
Contributor

squahtx commented Oct 11, 2021

There's a duplicate of this issue at #10721. Since that copy has more discussion, let's close this one and track the issue over there.

@squahtx squahtx closed this as completed Oct 11, 2021
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-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

4 participants