summary refs log tree commit diff
path: root/synapse/handlers/room.py
diff options
context:
space:
mode:
authorPatrick Cloke <clokep@users.noreply.github.com>2021-09-03 09:46:18 -0400
committerGitHub <noreply@github.com>2021-09-03 13:46:18 +0000
commit2cb85bdf7586f5094656dce6030922849fbbdb87 (patch)
treebe057cff1c4ce7906593e3cd6444d3a533492d43 /synapse/handlers/room.py
parentAdditional type hints for client REST servlets (part 5) (#10736) (diff)
downloadsynapse-2cb85bdf7586f5094656dce6030922849fbbdb87.tar.xz
Raise an error if an unknown preset is used to create a room. (#10738)
Raises a 400 error instead of a 500 if an unknown preset is passed
from a client to create a room.
Diffstat (limited to '')
-rw-r--r--synapse/handlers/room.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index b33fe09f77..ed780bb41f 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -909,7 +909,12 @@ class RoomCreationHandler(BaseHandler):
             )
             return last_stream_id
 
-        config = self._presets_dict[preset_config]
+        try:
+            config = self._presets_dict[preset_config]
+        except KeyError:
+            raise SynapseError(
+                400, f"'{preset_config}' is not a valid preset", errcode=Codes.BAD_JSON
+            )
 
         creation_content.update({"creator": creator_id})
         await send(etype=EventTypes.Create, content=creation_content)