diff options
author | Anshul Angaria <angaria.anshul38@gmail.com> | 2019-10-08 18:25:16 +0530 |
---|---|---|
committer | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2019-10-08 13:55:16 +0100 |
commit | 474abf1eb6852ca488fbf86d3da0622a457efef1 (patch) | |
tree | 3e65e7a8a78e4f62006cb198909ff78aedf15815 | |
parent | Remove unused public room list timeout param (#6179) (diff) | |
download | synapse-474abf1eb6852ca488fbf86d3da0622a457efef1.tar.xz |
add M_TOO_LARGE error code for uploading a too large file (#6151)
Fixes #6109
-rw-r--r-- | changelog.d/6109.bugfix | 1 | ||||
-rw-r--r-- | synapse/rest/media/v1/upload_resource.py | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/changelog.d/6109.bugfix b/changelog.d/6109.bugfix new file mode 100644 index 0000000000..da7ac1be4e --- /dev/null +++ b/changelog.d/6109.bugfix @@ -0,0 +1 @@ +Fix bug when uploading a large file: Synapse responds with `M_UNKNOWN` while it should be `M_TOO_LARGE` according to spec. Contributed by Anshul Angaria. diff --git a/synapse/rest/media/v1/upload_resource.py b/synapse/rest/media/v1/upload_resource.py index 5d76bbdf68..83d005812d 100644 --- a/synapse/rest/media/v1/upload_resource.py +++ b/synapse/rest/media/v1/upload_resource.py @@ -17,7 +17,7 @@ import logging from twisted.web.server import NOT_DONE_YET -from synapse.api.errors import SynapseError +from synapse.api.errors import Codes, SynapseError from synapse.http.server import ( DirectServeResource, respond_with_json, @@ -56,7 +56,11 @@ class UploadResource(DirectServeResource): if content_length is None: raise SynapseError(msg="Request must specify a Content-Length", code=400) if int(content_length) > self.max_upload_size: - raise SynapseError(msg="Upload request body is too large", code=413) + raise SynapseError( + msg="Upload request body is too large", + code=413, + errcode=Codes.TOO_LARGE, + ) upload_name = parse_string(request, b"filename", encoding=None) if upload_name: |