From ec606ea9e334a17af30a552e4612f96e8e7695fb Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Wed, 14 Oct 2020 05:24:58 -0500 Subject: [PATCH] Add correct M_BAD_JSON error code to /profile/{userId}/displayname (#8517) Fixes #8029 --- changelog.d/8517.bugfix | 1 + synapse/rest/client/v1/profile.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog.d/8517.bugfix diff --git a/changelog.d/8517.bugfix b/changelog.d/8517.bugfix new file mode 100644 index 000000000..1ab623c59 --- /dev/null +++ b/changelog.d/8517.bugfix @@ -0,0 +1 @@ +Fix error code for `/profile/{userId}/displayname` to be `M_BAD_JSON`. diff --git a/synapse/rest/client/v1/profile.py b/synapse/rest/client/v1/profile.py index b686cd671..e7fcd2b1f 100644 --- a/synapse/rest/client/v1/profile.py +++ b/synapse/rest/client/v1/profile.py @@ -59,7 +59,9 @@ class ProfileDisplaynameRestServlet(RestServlet): try: new_name = content["displayname"] except Exception: - return 400, "Unable to parse name" + raise SynapseError( + code=400, msg="Unable to parse name", errcode=Codes.BAD_JSON, + ) await self.profile_handler.set_displayname(user, requester, new_name, is_admin)