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

Commit 14a7371

Browse files
authored
Validate input parameters for the sendToDevice API. (#8975)
This makes the "messages" key in the content required. This is currently optional in the spec, but that seems to be an error.
1 parent cfcf554 commit 14a7371

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

changelog.d/8975.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add validation to the `sendToDevice` API to raise a missing parameters error instead of a 500 error.

synapse/rest/client/v2_alpha/sendtodevice.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from typing import Tuple
1818

1919
from synapse.http import servlet
20-
from synapse.http.servlet import parse_json_object_from_request
20+
from synapse.http.servlet import assert_params_in_dict, parse_json_object_from_request
2121
from synapse.logging.opentracing import set_tag, trace
2222
from synapse.rest.client.transactions import HttpTransactionCache
2323

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

5656
content = parse_json_object_from_request(request)
57+
assert_params_in_dict(content, ("messages",))
5758

5859
sender_user_id = requester.user.to_string()
5960

0 commit comments

Comments
 (0)