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

Traceback when fetching remote media #10318

Closed
moritzdietz opened this issue Jul 5, 2021 · 3 comments · Fixed by #10684
Closed

Traceback when fetching remote media #10318

moritzdietz opened this issue Jul 5, 2021 · 3 comments · Fixed by #10684
Labels
good first issue Good for newcomers S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@moritzdietz
Copy link
Contributor

Description

When I was watching the homeserver.log file I noticed the following lines going by.

2021-07-05 22:56:01,678 - synapse.http.server - 93 - ERROR - GET-114720 - Failed handle request via 'ThumbnailResource': <XForwardedForRequest at 0x7f74e7313400 method='GET' uri='/_matrix/media/r0/thumbnail/matrix.org/dOhWUOiqfTEPQASnYCLKLINu?width=800&height=600&method=scale' clientproto='HTTP/1.1' site='8008'>
Traceback (most recent call last):
  File "/opt/venvs/matrix-synapse/lib/python3.8/site-packages/synapse/http/server.py", line 258, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "/opt/venvs/matrix-synapse/lib/python3.8/site-packages/synapse/http/server.py", line 286, in _async_render
    callback_return = await raw_callback_return
  File "/opt/venvs/matrix-synapse/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 83, in _async_render_GET
    await self._respond_remote_thumbnail(
  File "/opt/venvs/matrix-synapse/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 265, in _respond_remote_thumbnail
    await self._select_and_respond_with_thumbnail(
  File "/opt/venvs/matrix-synapse/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 306, in _select_and_respond_with_thumbnail
    file_info = self._select_thumbnail(
  File "/opt/venvs/matrix-synapse/lib/python3.8/site-packages/synapse/rest/media/v1/thumbnail_resource.py", line 481, in _select_thumbnail
    thumbnail_info = min(info_list)[-1]
TypeError: '<' not supported between instances of 'dict' and 'dict'

I couldn't find an open or closed issue regarding this error so I thought I'd open an issue for it.

Steps to reproduce

I can reproduce it with curl

curl "https://matrix.moritzdietz.com/_matrix/media/r0/thumbnail/matrix.org/dOhWUOiqfTEPQASnYCLKLINu?width=800&height=600&method=scale"

which results in the error above.
I can fetch the media just fine via matrix.org:

curl -L "https://matrix-federation.matrix.org/_matrix/media/r0/thumbnail/matrix.org/dOhWUOiqfTEPQASnYCLKLINu?width=800&height=600&method=scale" -o somemedia.png

Version information

  • Homeserver: matrix.moritzdietz.com

If not matrix.org:

  • Version: 1.37.1

  • Install method: package manager

  • Platform: Ubuntu 20.04 Server

I have dynamic_thumbnails set to false (as it's the default).

@erikjohnston
Copy link
Member

What is your thumbnail_sizes config? I think you might hit this if it has duplicate values in it?

@erikjohnston erikjohnston added the X-Needs-Info This issue is blocked awaiting information from the reporter label Jul 23, 2021
@moritzdietz
Copy link
Contributor Author

I checked my yaml file and in neither the one shipped with my package manager nor the drop in yaml file in .conf.d/ has an activated yaml hash for that configuration.
Meaning: everything is commented out which controls the setting you mentioned.

My reasoning was that there must be some default and I can leave it like it is unless I really need to change or adapt it.

@erikjohnston erikjohnston added S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. and removed X-Needs-Info This issue is blocked awaiting information from the reporter labels Jul 26, 2021
@erikjohnston
Copy link
Member

The issue is here:

thumbnail_info = min(info_list)[-1]
, info_list is a list of tuples, where the last entry is a dict. I think what is happening is we're getting entries in there where all the numbers match, and so it tries and compares by the last entry in the tuple, which then fails. The fix would be to either a) deduplicate the list before sorting or b) using the key param to min to make the comparisons ignore the dict part.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants