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

Log when we get an invalid body on certain CS-API requests #13386

Closed
wants to merge 1 commit into from
Closed
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/13386.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Log when we get an invalid request body on room membership requests.
6 changes: 4 additions & 2 deletions synapse/rest/client/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,10 @@ async def on_POST(

try:
content = parse_json_object_from_request(request)
except Exception:
except Exception as e:
# Turns out we used to ignore the body entirely, and some clients
# cheekily send invalid bodies.
logger.warning("Ignoring invalid body on POST %s: %s", request.path, e)
content = {}

# twisted.web.server.Request.args is incorrectly defined as Optional[Any]
Expand Down Expand Up @@ -855,9 +856,10 @@ async def on_POST(

try:
content = parse_json_object_from_request(request)
except Exception:
except Exception as e:
# Turns out we used to ignore the body entirely, and some clients
# cheekily send invalid bodies.
logger.warning("Ignoring invalid body on POST %s: %s", request.path, e)
content = {}

if membership_action == "invite" and self._has_3pid_invite_keys(content):
Expand Down