Add correct M_BAD_JSON error code to /profile/{userId}/displayname (#8517)

Fixes #8029
This commit is contained in:
Aaron Raimist 2020-10-14 05:24:58 -05:00 committed by GitHub
parent 629a951b49
commit ec606ea9e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

1
changelog.d/8517.bugfix Normal file
View File

@ -0,0 +1 @@
Fix error code for `/profile/{userId}/displayname` to be `M_BAD_JSON`.

View File

@ -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)