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

Improve error messages of non-str displayname/avatar_url #8705

Merged
merged 2 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8705.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve the error returned when a non-string displayname or avatar_url is used when updating a user's profile.
8 changes: 6 additions & 2 deletions synapse/handlers/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ async def set_displayname(
)

if not isinstance(new_displayname, str):
raise SynapseError(400, "Invalid displayname")
raise SynapseError(
400, "'displayname' must be a string", errcode=Codes.INVALID_PARAM
)

if len(new_displayname) > MAX_DISPLAYNAME_LEN:
raise SynapseError(
Expand Down Expand Up @@ -273,7 +275,9 @@ async def set_avatar_url(
)

if not isinstance(new_avatar_url, str):
raise SynapseError(400, "Invalid displayname")
raise SynapseError(
400, "'avatar_url' must be a string", errcode=Codes.INVALID_PARAM
)

if len(new_avatar_url) > MAX_AVATAR_URL_LEN:
raise SynapseError(
Expand Down