forked-synapse/synapse/rest
Eric Eastwood 7b67e93d49
Provide more info why we don't have any thumbnails to serve (#13038)
Fix https://github.com/matrix-org/synapse/issues/13016

## New error code and status

### Before

Previously, we returned a `404` for `/thumbnail` which isn't even in the spec.

```json
{
  "errcode": "M_NOT_FOUND",
  "error": "Not found [b'hs1', b'tefQeZhmVxoiBfuFQUKRzJxc']"
}
```

### After

What does the spec say?

> 400: The request does not make sense to the server, or the server cannot thumbnail the content. For example, the client requested non-integer dimensions or asked for negatively-sized images.
>
> *-- https://spec.matrix.org/v1.1/client-server-api/#get_matrixmediav3thumbnailservernamemediaid*

Now with this PR, we respond with a `400` when we don't have thumbnails to serve and we explain why we might not have any thumbnails.

```json
{
    "errcode": "M_UNKNOWN",
    "error": "Cannot find any thumbnails for the requested media ([b'example.com', b'12345']). This might mean the media is not a supported_media_format=(image/jpeg, image/jpg, image/webp, image/gif, image/png) or that thumbnailing failed for some other reason. (Dynamic thumbnails are disabled on this server.)",
}
```

> Cannot find any thumbnails for the requested media ([b'example.com', b'12345']). This might mean the media is not a supported_media_format=(image/jpeg, image/jpg, image/webp, image/gif, image/png) or that thumbnailing failed for some other reason. (Dynamic thumbnails are disabled on this server.)


---

We still respond with a 404 in many other places. But we can iterate on those later and maybe keep some in some specific places after spec updates/clarification: https://github.com/matrix-org/matrix-spec/issues/1122

We can also iterate on the bugs where Synapse doesn't thumbnail when it should in other issues/PRs.
2022-07-15 11:42:21 -05:00
..
admin Fix "add user" admin api error when request contains a "msisdn" threepid (#13263) 2022-07-13 11:33:21 +01:00
client Reduce duplicate code in receipts servlets. (#13198) 2022-07-13 13:23:16 -04:00
consent Remove HomeServer.get_datastore() (#12031) 2022-02-23 11:04:02 +00:00
key Fix typechecker problems exposed by signedjson 1.1.2 (#12326) 2022-03-29 21:37:50 +00:00
media Provide more info why we don't have any thumbnails to serve (#13038) 2022-07-15 11:42:21 -05:00
synapse Drop support for delegating email validation (#13192) 2022-07-12 19:18:53 +01:00
__init__.py Remove user-visible groups/communities code (#12553) 2022-05-25 07:53:40 -04:00
health.py Add missing type hints to non-client REST servlets. (#10817) 2021-09-15 08:45:32 -04:00
well_known.py Add custom well-known (#13035) 2022-06-16 11:48:18 +01:00