From b6e9e353a1ac6c83873f6900bb66f9d12b7b307a Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 23 Oct 2024 16:20:26 +0200 Subject: [PATCH 1/4] Fix typo in error message when a media ID isn't known --- synapse/media/media_repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/media/media_repository.py b/synapse/media/media_repository.py index 0b742092322..24c3d0cfceb 100644 --- a/synapse/media/media_repository.py +++ b/synapse/media/media_repository.py @@ -259,7 +259,7 @@ async def verify_can_upload(self, media_id: str, auth_user: UserID) -> None: """ media = await self.store.get_local_media(media_id) if media is None: - raise SynapseError(404, "Unknow media ID", errcode=Codes.NOT_FOUND) + raise SynapseError(404, "Unknown media ID", errcode=Codes.NOT_FOUND) if media.user_id != auth_user.to_string(): raise SynapseError( From 27e6cd722d6c7027cfe1f9efb11ba03e595fd718 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 23 Oct 2024 16:22:14 +0200 Subject: [PATCH 2/4] Fix a few extra typos --- synapse/rest/media/upload_resource.py | 2 +- tests/rest/admin/test_federation.py | 2 +- tests/rest/admin/test_statistics.py | 2 +- tests/rest/admin/test_user.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/synapse/rest/media/upload_resource.py b/synapse/rest/media/upload_resource.py index 5ef6bf88364..359d006f041 100644 --- a/synapse/rest/media/upload_resource.py +++ b/synapse/rest/media/upload_resource.py @@ -94,7 +94,7 @@ def _get_file_metadata( # if headers.hasHeader(b"Content-Disposition"): # disposition = headers.getRawHeaders(b"Content-Disposition")[0] - # TODO(markjh): parse content-dispostion + # TODO(markjh): parse content-disposition return content_length, upload_name, media_type diff --git a/tests/rest/admin/test_federation.py b/tests/rest/admin/test_federation.py index c2015774a13..d5ae3345f50 100644 --- a/tests/rest/admin/test_federation.py +++ b/tests/rest/admin/test_federation.py @@ -96,7 +96,7 @@ def test_invalid_parameter(self) -> None: self.assertEqual(400, channel.code, msg=channel.json_body) self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"]) - # unkown order_by + # unknown order_by channel = self.make_request( "GET", self.url + "?order_by=bar", diff --git a/tests/rest/admin/test_statistics.py b/tests/rest/admin/test_statistics.py index 5f60e19e561..07ec49c4e59 100644 --- a/tests/rest/admin/test_statistics.py +++ b/tests/rest/admin/test_statistics.py @@ -82,7 +82,7 @@ def test_invalid_parameter(self) -> None: """ If parameters are invalid, an error is returned. """ - # unkown order_by + # unknown order_by channel = self.make_request( "GET", self.url + "?order_by=bar", diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py index 6982c7291a6..ca80e64b96d 100644 --- a/tests/rest/admin/test_user.py +++ b/tests/rest/admin/test_user.py @@ -717,7 +717,7 @@ def test_invalid_parameter(self) -> None: self.assertEqual(400, channel.code, msg=channel.json_body) self.assertEqual(Codes.INVALID_PARAM, channel.json_body["errcode"]) - # unkown order_by + # unknown order_by channel = self.make_request( "GET", self.url + "?order_by=bar", @@ -3694,7 +3694,7 @@ def test_limit_and_from_DELETE(self) -> None: @parameterized.expand(["GET", "DELETE"]) def test_invalid_parameter(self, method: str) -> None: """If parameters are invalid, an error is returned.""" - # unkown order_by + # unknown order_by channel = self.make_request( method, self.url + "?order_by=bar", From b4825d2806b939f512e3758b7c2d2fd59fff4b6f Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 23 Oct 2024 16:23:40 +0200 Subject: [PATCH 3/4] Use `NotFoundError` consistently in `verify_can_upload` --- synapse/media/media_repository.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/media/media_repository.py b/synapse/media/media_repository.py index 24c3d0cfceb..f4d25a7b8b9 100644 --- a/synapse/media/media_repository.py +++ b/synapse/media/media_repository.py @@ -259,7 +259,7 @@ async def verify_can_upload(self, media_id: str, auth_user: UserID) -> None: """ media = await self.store.get_local_media(media_id) if media is None: - raise SynapseError(404, "Unknown media ID", errcode=Codes.NOT_FOUND) + raise NotFoundError("Unknown media ID") if media.user_id != auth_user.to_string(): raise SynapseError( From 98c09f426ba431e4308fe22e5dc53ce6901a535b Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Fri, 25 Oct 2024 14:21:20 +0200 Subject: [PATCH 4/4] Add changelog. --- changelog.d/17865.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17865.misc diff --git a/changelog.d/17865.misc b/changelog.d/17865.misc new file mode 100644 index 00000000000..2303a7e1b74 --- /dev/null +++ b/changelog.d/17865.misc @@ -0,0 +1 @@ +Addressed some typos in docs and returned error message for unknown MXC ID.