matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Silent fail when generating remote thumbnails for pictures over homeserver's `max_image_pixels` #6435

Open GovanifY opened 4 years ago

GovanifY commented 4 years ago

Description

Let's say a homeserver A have a limit of 70M for its max_pixels (called max_image_pixels nowadays) thumbnailing scheme, while homeserver B have a limit, say, twice as low. A picture could be accepted as an avatar in homeserver A while homeserver B wouldn't be able to view this avatar as it wouldn't be able to generate thumbnails for this file.

More concrete example: https://matrix.org/_matrix/media/r0/download/matrix.org/JLjvxdzheErDJmtsHkbJraNQ is a 8192x8192 avatar. The default configuration for homeservers sets max_pixels as 32M, which is below matrix.org limit. This makes the avatar unviewable and it either reverts to the standard letter one or shows a broken image altogether in Riot.

At the very least we should make it so homeserver B does not return a M_NOT_FOUND but an actual error message. We might want to either force generation of thumbnails for avatars or add an UI to notify the user that it failed and to contact his system administrator.

Steps to reproduce

MadLittleMods commented 2 years ago

According to the spec, /_matrix/media/v3/thumbnail/{serverName}/{mediaId} should return a 413 when the local content is too large for the server to thumbnail or a 502 for remote content with the following error response:

{
  "errcode": "M_TOO_LARGE",
  "error": "Content is too large to thumbnail"
}
DMRobertson commented 1 year ago

Is this specific to avatars,or is there some way this affects other media pieces too?

MadLittleMods commented 1 year ago

Is this specific to avatars,or is there some way this affects other media pieces too?

I think it's general to all image media. When a thumbnail doesn't get generated, it's not obvious and appears as a generic failure.

The specific error codes I posted, might help distinguish the situation on the client.