forked-synapse/synapse/rest/media/v1
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
..
__init__.py Relax ignore-missing-imports for modules that have stubs now and update mypy (#11006) 2021-10-08 14:49:41 +01:00
_base.py Remove unnecessary pass statements. (#12206) 2022-03-11 07:06:21 -05:00
config_resource.py Use direct references for configuration variables (part 5). (#10897) 2021-09-24 07:25:21 -04:00
download_resource.py Add Cross-Origin-Resource-Policy header to thumbnail and download media endpoints (#12944) 2022-06-27 14:44:05 +01:00
filepath.py Fix media repository failing when media store path contains symlinks (#11446) 2021-12-02 16:05:24 +00:00
media_repository.py Prevent local quarantined media from being claimed by media retention (#12972) 2022-06-07 10:53:47 +00:00
media_storage.py Uniformize spam-checker API, part 5: expand other spam-checker callbacks to return Tuple[Codes, dict] (#13044) 2022-07-11 16:52:10 +00:00
oembed.py Fix preview of imgur and Tenor URLs. (#11669) 2022-01-18 13:20:24 -05:00
preview_html.py fix linting error from the 1.61.1 main -> develop merge 2022-06-28 16:47:04 +01:00
preview_url_resource.py Inline URL preview documentation. (#13261) 2022-07-12 15:01:58 -04:00
storage_provider.py Use ParamSpec in type hints for synapse.logging.context (#12150) 2022-03-08 15:58:14 +00:00
thumbnail_resource.py Provide more info why we don't have any thumbnails to serve (#13038) 2022-07-15 11:42:21 -05:00
thumbnailer.py Fix potential thumbnail memory leaks. (#12932) 2022-06-01 10:57:49 +00:00
upload_resource.py Remove HomeServer.get_datastore() (#12031) 2022-02-23 11:04:02 +00:00