summary refs log tree commit diff
path: root/synapse/events/__init__.py
diff options
context:
space:
mode:
authorRichard van der Hoff <1389908+richvdh@users.noreply.github.com>2019-05-21 13:47:25 +0100
committerGitHub <noreply@github.com>2019-05-21 13:47:25 +0100
commit04d53794d6848cca2567d67f494ba8405d0bf1cf (patch)
tree87512338fea4a3a1ba714060a472da88e169d4e4 /synapse/events/__init__.py
parentRevert "expose SlavedProfileStore to ClientReaderSlavedStore (#5200)" (diff)
downloadsynapse-04d53794d6848cca2567d67f494ba8405d0bf1cf.tar.xz
Fix error handling for rooms whose versions are unknown. (#5219)
If we remove support for a particular room version, we should behave more
gracefully. This should make client requests fail with a 400 rather than a 500,
and will ignore individiual PDUs in a federation transaction, rather than the
whole transaction.
Diffstat (limited to 'synapse/events/__init__.py')
-rw-r--r--synapse/events/__init__.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py

index badeb903fc..1edd19cc13 100644 --- a/synapse/events/__init__.py +++ b/synapse/events/__init__.py
@@ -21,6 +21,7 @@ import six from unpaddedbase64 import encode_base64 +from synapse.api.errors import UnsupportedRoomVersionError from synapse.api.room_versions import KNOWN_ROOM_VERSIONS, EventFormatVersions from synapse.util.caches import intern_dict from synapse.util.frozenutils import freeze @@ -369,12 +370,15 @@ def room_version_to_event_format(room_version): Returns: int + + Raises: + UnsupportedRoomVersionError if the room version is unknown """ v = KNOWN_ROOM_VERSIONS.get(room_version) if not v: - # We should have already checked version, so this should not happen - raise RuntimeError("Unrecognized room version %s" % (room_version,)) + # this can happen if support is withdrawn for a room version + raise UnsupportedRoomVersionError() return v.event_format