forked from MirrorHub/synapse
Improve error messages of non-str displayname/avatar_url (#8705)
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.
This commit is contained in:
parent
59cc2472b3
commit
e89bd3ea92
2 changed files with 7 additions and 2 deletions
1
changelog.d/8705.misc
Normal file
1
changelog.d/8705.misc
Normal file
|
@ -0,0 +1 @@
|
|||
Improve the error returned when a non-string displayname or avatar_url is used when updating a user's profile.
|
|
@ -189,7 +189,9 @@ class ProfileHandler(BaseHandler):
|
|||
)
|
||||
|
||||
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(
|
||||
|
@ -273,7 +275,9 @@ class ProfileHandler(BaseHandler):
|
|||
)
|
||||
|
||||
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(
|
||||
|
|
Loading…
Reference in a new issue