From 45067c102ba8b22ec96fb5a6201016bf65cbdc51 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 9 Dec 2019 14:22:24 +0000 Subject: [PATCH 1/2] Better errors regarding changing avatar_url --- synapse/rest/client/v1/profile.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/synapse/rest/client/v1/profile.py b/synapse/rest/client/v1/profile.py index 1eac8a44c5ae..4f47562c1be0 100644 --- a/synapse/rest/client/v1/profile.py +++ b/synapse/rest/client/v1/profile.py @@ -103,11 +103,16 @@ async def on_PUT(self, request, user_id): content = parse_json_object_from_request(request) try: - new_name = content["avatar_url"] + new_avatar_url = content.get("avatar_url") except Exception: - return 400, "Unable to parse name" + return 400, "Unable to parse avatar_url" + + if new_avatar_url is None: + return 400, "Missing required key: avatar_url" - await self.profile_handler.set_avatar_url(user, requester, new_name, is_admin) + await self.profile_handler.set_avatar_url( + user, requester, new_avatar_url, is_admin + ) return 200, {} From 3e5f3a96f6575840dd24ab9ec444f3ce3aca99d9 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Mon, 9 Dec 2019 14:27:14 +0000 Subject: [PATCH 2/2] Add changelog --- changelog.d/6497.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6497.bugfix diff --git a/changelog.d/6497.bugfix b/changelog.d/6497.bugfix new file mode 100644 index 000000000000..92ed08fc4077 --- /dev/null +++ b/changelog.d/6497.bugfix @@ -0,0 +1 @@ +Fix error message when setting your profile's avatar URL mentioning displaynames, and prevent NoneType avatar_urls. \ No newline at end of file