Better errors regarding changing avatar_url (#6497)

This commit is contained in:
Andrew Morgan 2019-12-09 14:54:33 +00:00 committed by GitHub
parent adfdd82b21
commit 5e8abe9013
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

1
changelog.d/6497.bugfix Normal file
View file

@ -0,0 +1 @@
Fix error message when setting your profile's avatar URL mentioning displaynames, and prevent NoneType avatar_urls.

View file

@ -103,11 +103,16 @@ class ProfileAvatarURLRestServlet(RestServlet):
content = parse_json_object_from_request(request) content = parse_json_object_from_request(request)
try: try:
new_name = content["avatar_url"] new_avatar_url = content.get("avatar_url")
except Exception: except Exception:
return 400, "Unable to parse name" return 400, "Unable to parse avatar_url"
await self.profile_handler.set_avatar_url(user, requester, new_name, is_admin) if new_avatar_url is None:
return 400, "Missing required key: avatar_url"
await self.profile_handler.set_avatar_url(
user, requester, new_avatar_url, is_admin
)
return 200, {} return 200, {}