Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when listing rooms in a space #17278

Open
hakkelt opened this issue Jun 6, 2024 · 3 comments
Open

Error when listing rooms in a space #17278

hakkelt opened this issue Jun 6, 2024 · 3 comments

Comments

@hakkelt
Copy link

hakkelt commented Jun 6, 2024

Description

Up until my most recent server upgrade, listing rooms in a space worked fine, but since then I receive the following error messages: It looks like your homeserver version does not support Spaces (Element Android), Error while loading rooms (app.element.io). The bug might have been introduced by #16785 (@erikjohnston @reivilibre), as changing line 783 at /synapse/storage/databases/main/state.py from

return super().get(key, default)

to

return super(StateMapWrapper, self).get(key, default)

apparently fixes the problem, and this line was introduced in the mentioned PR.

Steps to reproduce

  • Select a space and click "Explore rooms" in Element Android

Homeserver

private homeserver

Synapse Version

1.108.0

Installation Method

pip (from PyPI)

Database

single postgresql server

Workers

Single process

Platform

Fedora Linux 37 (Server Edition)
Python 3.11.6

Configuration

probably unrelated, but mautrix-meta bridge is configured

Relevant log output

2024-06-06 00:00:26,792 - synapse.metrics.background_process_metrics - 253 - ERROR - user_directory.notify_new_event-16462 - Background process 'user_directory.notify_new_event' threw an exception
Traceback (most recent call last):
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/metrics/background_process_metrics.py", line 251, in run
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/user_directory.py", line 181, in process
    await self._unsafe_process()
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/user_directory.py", line 247, in _unsafe_process
    await self._handle_deltas(deltas)
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/user_directory.py", line 275, in _handle_deltas
    await self._handle_room_membership_event(
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/user_directory.py", line 425, in _handle_room_membership_event
    await self._track_user_joined_room(room_id, state_key)
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/user_directory.py", line 434, in _track_user_joined_room
    is_public = await self.store.is_room_world_readable_or_publicly_joinable(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/storage/databases/main/user_directory.py", line 556, in is_room_world_readable_or_publicly_joinable
    join_rules_id = current_state_ids.get((EventTypes.JoinRules, ""))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/storage/databases/main/state.py", line 781, in get
    return super().get(key, default)
           ^^^^^^^
TypeError: super(type, obj): obj must be an instance or subtype of type

Anything else that would be useful to know?

No response

@anoadragon453
Copy link
Member

Hi @hakkelt, do you know which endpoint Element Android is calling when you complete the mentioned action?

The code in the logs should only get triggered by a user attempting to join a room, though I'm not sure why tapping on "Explore rooms" would cause that to happen.

Regardless, this does appear to be a bug. Would you be willing to toss your suggested change in a PR and we can merge it in?

@hakkelt
Copy link
Author

hakkelt commented Jun 7, 2024

I realized I had copied the wrong log entry (the one copied earlier was some other error caused by the same line). This is the one I get after trying to view the list of rooms in a space:

2024-06-07 23:08:57,365 - synapse.http.server - 146 - ERROR - GET-375 - Failed handle request via 'RoomHierarchyRestServlet': <XForwardedForRequest at 0x7f8374236190 method='GET' uri='/_matrix/client/v1/rooms/!<space id>/hierarchy?suggested_only=false&limit=20' clientproto='HTTP/1.1' site='8008'>
Traceback (most recent call last):
  File "/opt/synapse/lib/python3.11/site-packages/twisted/internet/defer.py", line 1697, in _inlineCallbacks
    result = context.run(gen.send, result)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/util/caches/response_cache.py", line 265, in cb
    return await callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/room_summary.py", line 187, in _get_room_hierarchy
    if not await self._is_local_room_accessible(requested_room_id, requester):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/handlers/room_summary.py", line 581, in _is_local_room_accessible
    join_rules_event_id = state_ids.get((EventTypes.JoinRules, ""))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/synapse/lib64/python3.11/site-packages/synapse/storage/databases/main/state.py", line 784, in get
    return super().get(key, default)
           ^^^^^^^
TypeError: super(type, obj): obj must be an instance or subtype of type

I would gladly create a PR, but I was unsure whether it was enough or if I should correct other calls to super() in other methods of the same class.

@devonh
Copy link
Member

devonh commented Jun 21, 2024

I think just fixing the one usage for now should be enough. This problem may be related to this issue: python-attrs/attrs#1038
Which would imply that only decorated methods exhibit this issue.

So rather than blindly trying to fix issues that may or may not exist, I think it would be best for the PR to be only for this one line:

return super().get(key, default)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants