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

Commit

Permalink
Return NOT_JSON if decode fails and defer set_timeline_upper_limit ca… (
Browse files Browse the repository at this point in the history
#14262)

* Return NOT_JSON if decode fails and defer set_timeline_upper_limit call until after check_valid_filter. Fixes #13661. Signed-off-by: Ryan Miguel <[email protected]>.

* Reword changelog
  • Loading branch information
renegaderyu authored Oct 24, 2022
1 parent 872ea2f commit 19c0e55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/14262.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Provide a specific error code when a `/sync` request provides a filter which doesn't represent a JSON object.
8 changes: 4 additions & 4 deletions synapse/rest/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ async def on_GET(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
elif filter_id.startswith("{"):
try:
filter_object = json_decoder.decode(filter_id)
set_timeline_upper_limit(
filter_object, self.hs.config.server.filter_timeline_limit
)
except Exception:
raise SynapseError(400, "Invalid filter JSON")
raise SynapseError(400, "Invalid filter JSON", errcode=Codes.NOT_JSON)
self.filtering.check_valid_filter(filter_object)
set_timeline_upper_limit(
filter_object, self.hs.config.server.filter_timeline_limit
)
filter_collection = FilterCollection(self.hs, filter_object)
else:
try:
Expand Down

0 comments on commit 19c0e55

Please sign in to comment.