element-hq / element-hq/synapse

Error when listing rooms in a space

Open
#17,278 3 comments 0 reactions 0 assignees View on GitHub
A-Spaces O-Occasional S-Minor T-Defect X-Regression
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

### 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
```python
return super().get(key, default)
```
to
```python
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

```shell
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_

Contributor guide

Open the contributing guide

Research direction

Start in synapse/storage/databases/main/state.py at StateMapWrapper.get, then trace the failing call from synapse/storage/databases/main/user_directory.py. Reproduce the space room-listing failure or run the relevant tests, and confirm that the TypeError no longer occurs and rooms can be listed after the change.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.