From 0248409bfade6a9eccf29efdd38d9003c0327a1d Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Wed, 6 Jan 2021 07:29:03 -0500 Subject: [PATCH] Handle a display name / avatar URL not included in a federation request. (#9023) These may be omitted if not set, but Synapse assumed they would be in the response. --- changelog.d/9023.bugfix | 1 + synapse/handlers/profile.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog.d/9023.bugfix diff --git a/changelog.d/9023.bugfix b/changelog.d/9023.bugfix new file mode 100644 index 000000000..deae64d93 --- /dev/null +++ b/changelog.d/9023.bugfix @@ -0,0 +1 @@ +Fix a longstanding issue where an internal server error would occur when requesting a profile over federation that did not include a display name / avatar URL. diff --git a/synapse/handlers/profile.py b/synapse/handlers/profile.py index dee0ef45e..36f9ee4b7 100644 --- a/synapse/handlers/profile.py +++ b/synapse/handlers/profile.py @@ -156,7 +156,7 @@ class ProfileHandler(BaseHandler): except HttpResponseException as e: raise e.to_synapse_error() - return result["displayname"] + return result.get("displayname") async def set_displayname( self, @@ -246,7 +246,7 @@ class ProfileHandler(BaseHandler): except HttpResponseException as e: raise e.to_synapse_error() - return result["avatar_url"] + return result.get("avatar_url") async def set_avatar_url( self,