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

500 error "min() arg is an empty sequence" when requesting a thumbnail #5117

Closed
darnir opened this issue May 1, 2019 · 8 comments
Closed
Labels
A-Media-Repository Uploading, downloading images and video, thumbnailing z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@darnir
Copy link

darnir commented May 1, 2019

Description

Looking at the logfile for my homeserver, I see the the following error message pop up fairly frequently:

2019-05-01 14:12:25,452 - synapse.http.server - 112 - ERROR - GET-38086 - Failed handle request via 'ThumbnailResource': <XForwardedForRequest at 0x7fe3dd9286a0 method='GET' uri='/_matrix/media/v1/thumbnail/raim.ist/KthgQjZpYLHEVOIzwvTjkXPx?width=150&height=150&method=scale' clientproto='HTTP/1.0' site=8008>
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python3.6/site-packages/synapse/storage/_base.py", line 460, in runWithConnection
    defer.returnValue(result)
  File "/usr/lib/python3.6/site-packages/twisted/internet/defer.py", line 1362, in returnValue
    raise _DefGen_Return(val)
twisted.internet.defer._DefGen_Return: [{'thumbnail_width': 10, 'thumbnail_height': 10, 'thumbnail_method': 'crop', 'thumbnail_type': 'image/jpeg', 'thumbnail_length': 715, 'filesystem_id': 'ZsQNhbXXFdIhkmfWZvdvlAww'}]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python3.6/site-packages/synapse/storage/_base.py", line 418, in runInteraction
    defer.returnValue(result)
  File "/usr/lib/python3.6/site-packages/twisted/internet/defer.py", line 1362, in returnValue
    raise _DefGen_Return(val)
twisted.internet.defer._DefGen_Return: [{'thumbnail_width': 10, 'thumbnail_height': 10, 'thumbnail_method': 'crop', 'thumbnail_type': 'image/jpeg', 'thumbnail_length': 715, 'filesystem_id': 'ZsQNhbXXFdIhkmfWZvdvlAww'}]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/synapse/http/server.py", line 81, in wrapped_request_handler
    yield h(self, request)
  File "/usr/lib/python3.6/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/lib/python3.6/site-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/lib/python3.6/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 83, in _async_render_GET
    width, height, method, m_type
  File "/usr/lib/python3.6/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python3.6/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 244, in _respond_remote_thumbnail
    width, height, method, m_type, thumbnail_infos
  File "/usr/lib/python3.6/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 317, in _select_thumbnail
    return min(info_list2)[-1]
ValueError: min() arg is an empty sequence

There are 10s of such messages every day.

Steps to reproduce

I don't currently know what action can cause this error.

Version information

  • Homeserver: My own HS

If not matrix.org:

  • Version: 0.99.3

  • Install method: pip3

  • Platform:

Running inside a Alpine Linux LXC container on a Arch Linux host

@darnir
Copy link
Author

darnir commented May 10, 2019

Any suggestions / hints on why I'm seeing this and what can be done about it?

@darnir
Copy link
Author

darnir commented May 19, 2019

Anything at all? At the very least an acknowledgement of the issue would be nice.

If there's more info required, please let me know

@richvdh
Copy link
Member

richvdh commented May 21, 2019

an acknowledgement of the issue would be nice.

sorry, not sure what I can say. Looks like an error. don't know what causes it, other than (obviously) it's related to thumbnails.

@richvdh
Copy link
Member

richvdh commented Apr 2, 2020

possibly a dup of #3183

@darnir
Copy link
Author

darnir commented Apr 24, 2020

I don't think so. I still see such errors in my logs. I'm happy to help in any way I can to debug this.

@richvdh richvdh changed the title "Failed Handle Request" error in log file 500 error "min() arg is an empty sequence" when requesting a thumbnail Apr 24, 2020
@richvdh richvdh added z-bug (Deprecated Label) A-Media-Repository Uploading, downloading images and video, thumbnailing z-p2 (Deprecated Label) labels Apr 24, 2020
@richvdh
Copy link
Member

richvdh commented Apr 24, 2020

possibly a dup of #3183

this was the wrong link. I think I meant #3763. Or possibly #3813? However, I don't think it is really a dup of either of those. The root cause seems to be that a scaled thumbnail has been requested, but no scaled thumbnail has been generated for that image.

@FlyveHest
Copy link

I have just installed a Synapse server from the latest docker image (matrixdotorg/synapse:latest), and I am experiencing the same thing.

Feb 1 20:55:50 server docker/synapse[1746]: 2021-02-01 20:55:50,974 - synapse.http.server - 79 - ERROR - GET-13559 - Failed handle request via 'ThumbnailResource': <XForwardedForRequest at 0x7f309cfbeac0 method='GET' uri='/_matrix/media/r0/thumbnail/server.name/RdKqjaYyUAbouqMHCeVCbese?width=16&height=16&method=crop' clientproto='HTTP/1.1' site='8008'>
Feb 1 20:55:50 server docker/synapse[1746]: Traceback (most recent call last):
Feb 1 20:55:50 server docker/synapse[1746]: File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 224, in _async_render_wrapper
Feb 1 20:55:50 server docker/synapse[1746]: callback_return = await self._async_render(request)
Feb 1 20:55:50 server docker/synapse[1746]: File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 252, in _async_render
Feb 1 20:55:50 server docker/synapse[1746]: callback_return = await raw_callback_return
Feb 1 20:55:50 server docker/synapse[1746]: File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 74, in _async_render_GET
Feb 1 20:55:50 server docker/synapse[1746]: await self._respond_local_thumbnail(
Feb 1 20:55:50 server docker/synapse[1746]: File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 111, in _respond_local_thumbnail
Feb 1 20:55:50 server docker/synapse[1746]: thumbnail_info = self._select_thumbnail(
Feb 1 20:55:50 server docker/synapse[1746]: File "/usr/local/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 352, in _select_thumbnail
Feb 1 20:55:50 server docker/synapse[1746]: return min(crop_info_list2)[-1]
Feb 1 20:55:50 server docker/synapse[1746]: ValueError: min() arg is an empty sequence

@clokep
Copy link
Member

clokep commented Feb 1, 2021

This should be fixed by #9163 in Synapse v1.27.0. Forgot to link the issues.

@clokep clokep closed this as completed Feb 1, 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