Compare commits

...

3 Commits

Author SHA1 Message Date
Alex Durham
8549c3e314
Merge c1d19462f95000f3a7b3edcb9555a2fc44b694f9 into a2bee2f255853c6e019e1651a168c12dff64d68f 2025-06-30 16:02:02 +02:00
SnackEngineer
c1d19462f9 Add changelog entry 2025-06-24 10:11:25 +02:00
SnackEngineer
67dd3d4535 Don't send null values in response to federation profile queries
Don't send the fields `avatar_url` and `displayname` when
they are not defined for the queried user.

Before this change they would be sent and set to null in the JSON response object,
which would violate the OpenAPI definitions
(c.f. https://spec.matrix.org/v1.11/server-server-api/#get_matrixfederationv1queryprofile).
2025-06-24 09:50:34 +02:00
2 changed files with 11 additions and 4 deletions

1
changelog.d/18593.bugfix Normal file
View File

@ -0,0 +1 @@
Fix avatar_url and displayname being sent on profile queries when they are null.

View File

@ -539,11 +539,17 @@ class ProfileHandler:
response: JsonDict = {} response: JsonDict = {}
try: try:
if just_field is None or just_field == ProfileFields.DISPLAYNAME: if just_field is None or just_field == ProfileFields.DISPLAYNAME:
response["displayname"] = await self.store.get_profile_displayname(user) displayname = await self.store.get_profile_displayname(user)
# do not set the displayname field if it is None,
# since then we send a null in the JSON response
if displayname is not None:
response["displayname"] = displayname
if just_field is None or just_field == ProfileFields.AVATAR_URL: if just_field is None or just_field == ProfileFields.AVATAR_URL:
response["avatar_url"] = await self.store.get_profile_avatar_url(user) avatar_url = await self.store.get_profile_avatar_url(user)
# do not set the avatar_url field if it is None,
# since then we send a null in the JSON response
if avatar_url is not None:
response["avatar_url"] = avatar_url
if self.hs.config.experimental.msc4133_enabled: if self.hs.config.experimental.msc4133_enabled:
if just_field is None: if just_field is None:
response.update(await self.store.get_profile_fields(user)) response.update(await self.store.get_profile_fields(user))