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

Commit

Permalink
Improve error messages of non-str displayname/avatar_url (#8705)
Browse files Browse the repository at this point in the history
This PR fixes two things:

* Corrects the copy/paste error of telling the client their displayname is wrong when they are submitting an `avatar_url`.
* Returns a `M_INVALID_PARAM` instead of `M_UNKNOWN` for non-str type parameters.

Reported by @t3chguy.
  • Loading branch information
anoadragon453 authored Nov 2, 2020
1 parent 59cc247 commit e89bd3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit e89bd3e

Please sign in to comment.