diff options
-rw-r--r-- | changelog.d/11638.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/state.py | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/changelog.d/11638.misc b/changelog.d/11638.misc new file mode 100644 index 0000000000..76dfb56bda --- /dev/null +++ b/changelog.d/11638.misc @@ -0,0 +1 @@ +Improve the error messages from `get_create_event_for_room`. diff --git a/synapse/storage/databases/main/state.py b/synapse/storage/databases/main/state.py index 7e5a6aae18..2fb3e65192 100644 --- a/synapse/storage/databases/main/state.py +++ b/synapse/storage/databases/main/state.py @@ -177,11 +177,15 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore): NotFoundError if the room is unknown """ state_ids = await self.get_current_state_ids(room_id) + + if not state_ids: + raise NotFoundError(f"Current state for room {room_id} is empty") + create_id = state_ids.get((EventTypes.Create, "")) # If we can't find the create event, assume we've hit a dead end if not create_id: - raise NotFoundError("Unknown room %s" % (room_id,)) + raise NotFoundError(f"No create event in current state for room {room_id}") # Retrieve the room's create event and return create_event = await self.get_event(create_id) |