Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Providing avatar_url in PUT /_synapse/admin/v2/users/<user_id> will cause the request to fail #8871

Closed
Half-Shot opened this issue Dec 3, 2020 · 2 comments · Fixed by #8872
Labels
A-Admin-API z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@Half-Shot
Copy link
Collaborator

Half-Shot commented Dec 3, 2020

2020-12-03 17:54:46,740 - synapse.http.server - 79 - ERROR - PUT-4829- Failed handle request via 'UserRestServletV2': <XForwardedForRequest at 0x7fea0361d880 method='PUT' uri='/_synapse/admin/v2/users/%40demo2_fake%3Ahs-mi1-staging.ems.host' clientproto='HTTP/1.1' site=8008>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 228, in _async_render_wrapper
    callback_return = await self._async_render(request)
  File "/usr/local/lib/python3.8/site-packages/synapse/http/server.py", line 405, in _async_render
    callback_return = await raw_callback_return
  File "/usr/local/lib/python3.8/site-packages/synapse/rest/admin/users.py", line 321, in on_PUT
    await self.profile_handler.set_avatar_url(
  File "/usr/local/lib/python3.8/site-packages/synapse/handlers/profile.py", line 264, in set_avatar_url
    if not self.hs.is_mine(target_user):
  File "/usr/local/lib/python3.8/site-packages/synapse/server.py", line 297, in is_mine
    return domain_specific_string.domain == self.hostname
AttributeError: 'str' object has no attribute 'domain'

if "avatar_url" in body and type(body["avatar_url"]) == str:
await self.profile_handler.set_avatar_url(
target_user, requester, body["avatar_url"], True
)

Synapse 1.23.0

@Half-Shot Half-Shot changed the title Providing "avatar_url" Providing avatar_url in PUT /_synapse/admin/v2/users/<user_id> will cause the request to fail Dec 3, 2020
@clokep
Copy link
Contributor

clokep commented Dec 3, 2020

I think it should be using user_id instead of target_user. Seems that line 193 might also have that issue.

@clokep
Copy link
Contributor

clokep commented Dec 3, 2020

I think it should be using user_id instead of target_user. Seems that line 193 might also have that issue.

Oops. I read this code backwards, seems that the caller on line 220 is correct, and the one on 321 is wrong. 😄

Half-Shot added a commit that referenced this issue Dec 7, 2020
* Call set_avatar_url with target_user, not user_id

Fixes #8871

* Create 8872.bugfix

* Update synapse/rest/admin/users.py

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>

* Testing

* Update changelog.d/8872.bugfix

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>

Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Admin-API z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants