Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit ec606ea

Browse files
authored
Add correct M_BAD_JSON error code to /profile/{userId}/displayname (#8517)
Fixes #8029
1 parent 629a951 commit ec606ea

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

changelog.d/8517.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix error code for `/profile/{userId}/displayname` to be `M_BAD_JSON`.

synapse/rest/client/v1/profile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ async def on_PUT(self, request, user_id):
5959
try:
6060
new_name = content["displayname"]
6161
except Exception:
62-
return 400, "Unable to parse name"
62+
raise SynapseError(
63+
code=400, msg="Unable to parse name", errcode=Codes.BAD_JSON,
64+
)
6365

6466
await self.profile_handler.set_displayname(user, requester, new_name, is_admin)
6567

0 commit comments

Comments
 (0)