summary refs log tree commit diff
diff options
context:
space:
mode:
authorRyan Miguel <1818590+renegaderyu@users.noreply.github.com>2022-10-24 08:55:06 -0700
committerGitHub <noreply@github.com>2022-10-24 16:55:06 +0100
commit19c0e55ef7742d67cff1cb6fb7c3e862b86ea788 (patch)
treecf862e48e819cba48aaa617e6154237a58a77e9a
parentBump serde_json from 1.0.86 to 1.0.87 (#14279) (diff)
downloadsynapse-19c0e55ef7742d67cff1cb6fb7c3e862b86ea788.tar.xz
Return NOT_JSON if decode fails and defer set_timeline_upper_limit ca… (#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 <miguel.ryanj@gmail.com>.

* Reword changelog
Diffstat (limited to '')
-rw-r--r--changelog.d/14262.misc1
-rw-r--r--synapse/rest/client/sync.py8
2 files changed, 5 insertions, 4 deletions
diff --git a/changelog.d/14262.misc b/changelog.d/14262.misc
new file mode 100644
index 0000000000..c1d23bc67d
--- /dev/null
+++ b/changelog.d/14262.misc
@@ -0,0 +1 @@
+Provide a specific error code when a `/sync` request provides a filter which doesn't represent a JSON object.
diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py
index 8a16459105..f2013faeb2 100644
--- a/synapse/rest/client/sync.py
+++ b/synapse/rest/client/sync.py
@@ -146,12 +146,12 @@ class SyncRestServlet(RestServlet):
         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: