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

Validate input parameters for the sendToDevice API. #8975

Merged
merged 5 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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/8975.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add validation to the `sendToDevice` API to raise a missing parameters error instead of a 500 error.
3 changes: 2 additions & 1 deletion synapse/rest/client/v2_alpha/sendtodevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Tuple

from synapse.http import servlet
from synapse.http.servlet import parse_json_object_from_request
from synapse.http.servlet import assert_params_in_dict, parse_json_object_from_request
from synapse.logging.opentracing import set_tag, trace
from synapse.rest.client.transactions import HttpTransactionCache

Expand Down Expand Up @@ -54,6 +54,7 @@ async def _put(self, request, message_type, txn_id):
requester = await self.auth.get_user_by_req(request, allow_guest=True)

content = parse_json_object_from_request(request)
assert_params_in_dict(content, ("messages",))

sender_user_id = requester.user.to_string()

Expand Down