element-hq / element-hq/synapse

Failed handle request via 'RoomHierarchyRestServlet', KeyError: ('m.room.create', '')

Open
#12,082 0 comments 0 reactions 0 assignees View on GitHub
A-Spaces T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#12082](https://github.com/matrix-org/synapse/issues/12082).

---

### Description

Listing all the rooms belonging to some private Space on the "Manage & explore
rooms" page fails with an "Internal Server Error" from Element web and Android.

Filtering the rooms with the panel on the left outside of this page works fine
otherwise.

### Steps to reproduce

This error only seems to happen in one particular private space, but not
other ones.

- List all the rooms in a space through "Manage & explore rooms".
- Scroll down the list, trying to load all elements, until the error shows up.

The following error appears in loop in Synapse's logs:

```log
synapse.http.server: [GET-1572871] Failed handle request via 'RoomHierarchyRestServlet':
Traceback (most recent call last):
File "/nix/store/dv9mv0fmmhkbxczqflhcq6ifvkcvyr72-python3.9-Twisted-21.7.0/lib/python3.9/site-packages/twisted/internet/defer.py", line 1661, in _inlineCallbacks
result = current_context.run(gen.send, result)
File "/nix/store/rp1cyyj9sbwq8xf41d334wxhlh5i2rvl-matrix-synapse-1.52.0/lib/python3.9/site-packages/synapse/util/caches/response_cache.py", line 246, in cb
return await callback(*args, **kwargs)
File "/nix/store/rp1cyyj9sbwq8xf41d334wxhlh5i2rvl-matrix-synapse-1.52.0/lib/python3.9/site-packages/synapse/handlers/room_summary.py", line 396, in _get_room_hierarchy
room_entry = await self._summarize_local_room(
File "/nix/store/rp1cyyj9sbwq8xf41d334wxhlh5i2rvl-matrix-synapse-1.52.0/lib/python3.9/site-packages/synapse/handlers/room_summary.py", line 654, in _summarize_local_room
room_entry = await self._build_room_entry(room_id, for_federation=bool(origin))
File "/nix/store/rp1cyyj9sbwq8xf41d334wxhlh5i2rvl-matrix-synapse-1.52.0/lib/python3.9/site-packages/synapse/handlers/room_summary.py", line 996, in _build_room_entry
current_state_ids[(EventTypes.Create, "")]
KeyError: ('m.room.create', '')
```

I previously had issues with creating some room in that space due to another
server in the federation being offline. I speculate that some room might have
been partially created and partially added to the space.

The end of that traceback seems similar to the one of #10032.

### Version information

If not matrix.org:

- **Version**: 1.52.0, Python 3.9.6
- **Install method**: distro package
- **Platform**: NixOS Linux, x86

Contributor guide

Open the contributing guide

Research direction

Start at synapse/handlers/room_summary.py, especially _get_room_hierarchy, _summarize_local_room, and _build_room_entry, using the RoomHierarchyRestServlet request as the entry point. Reproduce listing all rooms in the affected private Space and trace why current_state_ids lacks ('m.room.create', ''). Done means the hierarchy request no longer returns an Internal Server Error for such a room.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.