mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 18:43:53 +01:00
Suppress empty body warnings in room servelets (#14600)
* Suppress empty body warnings in room servelets We've already decided to allow empty bodies for backwards compat. The change here stops us from emitting a misleading warning; see also https://github.com/matrix-org/synapse/issues/14478#issuecomment-1319157105 * Changelog
This commit is contained in:
parent
05eb55f57d
commit
93ac3c197e
2 changed files with 3 additions and 12 deletions
1
changelog.d/14600.bugfix
Normal file
1
changelog.d/14600.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Suppress a spurious warning when `POST /rooms/<room_id>/<membership>/`, `POST /join/<room_id_or_alias`, or the unspecced `PUT /join/<room_id_or_alias>/<txn_id>` receive an empty HTTP request body.
|
|
@ -396,12 +396,7 @@ class JoinRoomAliasServlet(ResolveRoomIdMixin, TransactionRestServlet):
|
||||||
) -> Tuple[int, JsonDict]:
|
) -> Tuple[int, JsonDict]:
|
||||||
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
||||||
|
|
||||||
try:
|
content = parse_json_object_from_request(request, allow_empty_body=True)
|
||||||
content = parse_json_object_from_request(request)
|
|
||||||
except Exception:
|
|
||||||
# Turns out we used to ignore the body entirely, and some clients
|
|
||||||
# cheekily send invalid bodies.
|
|
||||||
content = {}
|
|
||||||
|
|
||||||
# twisted.web.server.Request.args is incorrectly defined as Optional[Any]
|
# twisted.web.server.Request.args is incorrectly defined as Optional[Any]
|
||||||
args: Dict[bytes, List[bytes]] = request.args # type: ignore
|
args: Dict[bytes, List[bytes]] = request.args # type: ignore
|
||||||
|
@ -952,12 +947,7 @@ class RoomMembershipRestServlet(TransactionRestServlet):
|
||||||
}:
|
}:
|
||||||
raise AuthError(403, "Guest access not allowed")
|
raise AuthError(403, "Guest access not allowed")
|
||||||
|
|
||||||
try:
|
content = parse_json_object_from_request(request, allow_empty_body=True)
|
||||||
content = parse_json_object_from_request(request)
|
|
||||||
except Exception:
|
|
||||||
# Turns out we used to ignore the body entirely, and some clients
|
|
||||||
# cheekily send invalid bodies.
|
|
||||||
content = {}
|
|
||||||
|
|
||||||
if membership_action == "invite" and all(
|
if membership_action == "invite" and all(
|
||||||
key in content for key in ("medium", "address")
|
key in content for key in ("medium", "address")
|
||||||
|
|
Loading…
Reference in a new issue