Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Raise an error if an unknown preset is passed from a client. #10738

Merged
merged 2 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/10738.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Additional error checking for the `preset` field when creating a room.
7 changes: 6 additions & 1 deletion synapse/handlers/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,12 @@ async def send(etype: str, content: JsonDict, **kwargs) -> int:
)
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)
Expand Down