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

Admin API: /_synapse/admin/v1/room/[room-id]/media always throws 500 error #5737

Closed

Description

@zingi

Description

The ListMediaInRoom from the admin API does not get the auth token from the request. So every request to /_synapse/admin/v1/room/[room-id]/media fails with the error:

{
  "errcode": "M_UNKNOWN",
  "error": "Internal server error"
}
class ListMediaInRoom(RestServlet):
    """Lists all of the media in a given room.
    """

    PATTERNS = historical_admin_path_patterns("/room/(?P<room_id>[^/]+)/media")

    def __init__(self, hs):
        self.store = hs.get_datastore()

       # -------------------------
       # I guess here is missing:   
       # self.auth = hs.get_auth() 
       # ------------------------- 

    @defer.inlineCallbacks
    def on_GET(self, request, room_id):
        requester = yield self.auth.get_user_by_req(request)
        is_admin = yield self.auth.is_server_admin(requester.user)
        if not is_admin:
            raise AuthError(403, "You are not a server admin")

        local_mxcs, remote_mxcs = yield self.store.get_media_mxcs_in_room(room_id)

        defer.returnValue((200, {"local": local_mxcs, "remote": remote_mxcs}))

Steps to reproduce

  • Make a request to this endpoint.

It should return a list of the stored media in this room but always throws an error.

Version information

  • Homeserver: personal homeserver with ​restricted federation

If not matrix.org:

  • Version: v1.1.0 avhost docker

  • Install method: docker-compose up -d

  • Platform: VPS with Debian 9 64bit

Activity

  1. richvdh commented on Jul 23, 2019

    @richvdh
    Member

    can you share the stacktrace from the logs please?

  2. zingi commented on Jul 23, 2019

    @zingi
    Author
    2019-07-23T09:48:49.021143764Z 2019-07-23 09:48:49,020 - synapse.access.http.8008 - 233 - INFO - GET-15871 - 31.207.121.246 - 8008 - Received request: GET /_synapse/admin/v1/room/[myCensoredRoomId]/media
    2019-07-23T09:48:49.030009483Z 2019-07-23 09:48:49,026 - synapse.http.server - 108 - ERROR - GET-15871 - Failed handle request via 'ListMediaInRoom': <XForwardedForRequest at 0x7fe5793bd828 method='GET' uri='/_synapse/admin/v1/room/[myCensoredRoomId]/media' clientproto='HTTP/1.1' site=8008>
    2019-07-23T09:48:49.030093209Z Traceback (most recent call last):
    2019-07-23T09:48:49.061530539Z   File "/usr/local/lib/python3.5/dist-packages/synapse/http/server.py", line 76, in wrapped_request_handler
    2019-07-23T09:48:49.061566987Z     await h(self, request)
    2019-07-23T09:48:49.061575157Z   File "/usr/local/lib/python3.5/dist-packages/synapse/http/server.py", line 301, in _async_render
    2019-07-23T09:48:49.061582306Z     callback_return = await callback_return
    2019-07-23T09:48:49.061589110Z   File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    2019-07-23T09:48:49.061596291Z     result = g.send(result)
    2019-07-23T09:48:49.061602967Z   File "/usr/local/lib/python3.5/dist-packages/synapse/rest/admin/__init__.py", line 582, in on_GET
    2019-07-23T09:48:49.061609976Z     requester = yield self.auth.get_user_by_req(request)
    2019-07-23T09:48:49.061616695Z AttributeError: 'ListMediaInRoom' object has no attribute 'auth'
    2019-07-23T09:48:49.061670239Z 2019-07-23 09:48:49,034 - synapse.access.http.8008 - 302 - INFO - GET-15871 - 31.207.121.246 - 8008 - {None} Processed request: 0.014sec/0.001sec (0.000sec, 0.004sec) (0.000sec/0.000sec/0) 55B 500 "GET /_synapse/admin/v1/room/[myCensoredRoomId]/media HTTP/1.1" "insomnia/6.5.4" [0 dbevts]
    
  3. richvdh commented on Jul 23, 2019

    @richvdh
    Member

    thanks

  4. changed the title [-]Admin API: ListMediaInRoom does not fetch auth token from request; throws always error[/-] [+]Admin API: `/_synapse/admin/v1/room/[room-id]/media` always throws 500 error[/+] on Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions