-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
A filtered /sync
for a specific room does not include account_data or ephemeral events in its response
#13648
Comments
this looks like a bug. |
hello, |
To summarise the report: the filter
only includes timeline events for that room in the /sync response. It does not include account_data or ephemeral events. |
/sync
for a specific room does not include account_data or ephemeral events in the response
/sync
for a specific room does not include account_data or ephemeral events in the response/sync
for a specific room does not include account_data or ephemeral events in its response
@andreidiaconescu could you please either put the "response without filter" into a GitHub Gist or hide that away with a collapsing section? Thanks in advance |
@Zocker1999NET done, i hope it's ok. |
Sanity check: do you see this when running against the latest version of Synapse (1.65)? |
I seem to be able to reproduce this on matrix.org:
|
I've narrowed this down to here synapse/synapse/handlers/sync.py Lines 2278 to 2282 in 5e7847d
In a test with the initial state >>> syncconfig.filter_collection
<FilterCollection {"room": {"rooms": ["!zIIoSoJpiOZzAWRpql:test"]}}>
>>> account_data_events
[{'type': 'org.matrix.foo', 'content': {'bar': 'baz'}}] that snippet redefines account_data_events to the empty list. |
The call to synapse/synapse/api/filtering.py Lines 268 to 273 in c52abc1
Has this been broken for ages? |
Looks to have been introduced here, in Synpase 0.34.0. For some reason that commit made it so that per-room account data checks must pass the This is an example where Matrix sloppily calls all sorts of JSON objects I would guess that reverting the highlighted lines would suffice to fix the reported symptoms. But I'd be hesitant to do that without understanding the original motivation behind #454. Maybe just an oversight, or maybe there were spec changes between then and now. |
Test that reproduces this: diff --git a/tests/rest/client/test_sync.py b/tests/rest/client/test_sync.py
index de0dec853..8db513031 100644
--- a/tests/rest/client/test_sync.py
+++ b/tests/rest/client/test_sync.py
@@ -14,7 +14,9 @@
# limitations under the License.
import json
from http import HTTPStatus
from typing import List, Optional
+from urllib.parse import urlencode
from parameterized import parameterized
@@ -28,7 +30,16 @@
ReceiptTypes,
RelationTypes,
)
-from synapse.rest.client import devices, knock, login, read_marker, receipts, room, sync
+from synapse.rest.client import (
+ devices,
+ knock,
+ login,
+ read_marker,
+ receipts,
+ room,
+ sync,
+ account_data,
+)
from synapse.server import HomeServer
from synapse.types import JsonDict
from synapse.util import Clock
@@ -63,6 +74,7 @@ class SyncFilterTestCase(unittest.HomeserverTestCase):
room.register_servlets,
login.register_servlets,
sync.register_servlets,
+ account_data.register_servlets,
]
def test_sync_filter_labels(self) -> None:
@@ -189,6 +201,61 @@ def _test_sync_filter_labels(self, sync_filter: str) -> List[JsonDict]:
return channel.json_body["rooms"]["join"][room_id]["timeline"]["events"]
+ def test_account_data_included_when_filtering_to_room(self) -> None:
+ # Create a user and have them create a room.
+ user_id = self.register_user("kermit", "test")
+ tok = self.login("kermit", "test")
+ room_id = self.helper.create_room_as(user_id, tok=tok)
+
+ # Send an event to that room.
+ event_id = self.helper.send_event(
+ room_id=room_id,
+ type=EventTypes.Message,
+ content={
+ "msgtype": "m.text",
+ "body": "it's not easy being green",
+ },
+ tok=tok,
+ )["event_id"]
+
+ # Set some account data for that room.
+ account_data_type = "org.matrix.foo"
+ account_data_content = {"bar": "baz"}
+ channel = self.make_request(
+ "PUT",
+ f"/user/{user_id}/rooms/{room_id}/account_data/{account_data_type}",
+ account_data_content,
+ access_token=tok,
+ )
+ self.assertEqual(channel.code, 200, channel.json_body)
+
+ # Request an initial sync for the room, filtered to only include this room.
+ query_params = {
+ "filter": json.dumps({"room": {"rooms": [room_id]}}),
+ "timeout": "10",
+ }
+ channel = self.make_request(
+ "GET",
+ f"/sync?{urlencode(query_params)}",
+ access_token=tok,
+ )
+ self.assertEqual(channel.code, 200, channel.json_body)
+ timeline_events = {
+ e["event_id"]
+ for e in channel.json_body["rooms"]["join"][room_id]["timeline"]["events"]
+ }
+ account_data_events = [
+ e
+ for e in channel.json_body["rooms"]["join"][room_id]["account_data"][
+ "events"
+ ]
+ ]
+ self.assertIn(event_id, timeline_events)
+ self.assertEqual(
+ account_data_events,
+ [{"type": account_data_type, "content": account_data_content}],
+ )
+
class SyncTypingTests(unittest.HomeserverTestCase):
|
Is there any possibility this get a fix? |
Description
I use the /sync endpoint with and without filters as JSON;
As filter i specify only one room id (!OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech), and i indeed get only that room in rooms->join->[room id] and there are no events under
[room id]->account_data -> events or [room id]->ephemeral -> events.
If i do not specify any filter, i get more rooms, including the one with id: !OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech
but there are events under: [room id]->account_data -> events and [room id]->ephemeral -> events for exactly the room with id !OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech
Steps to reproduce
and there are events under: [room id]->account_data -> events and [room id]->ephemeral -> events
http://synapse:8008/_matrix/client/v3/sync?user_id=@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech&
[room id]->account_data -> events or [room id]->ephemeral -> events.
http://synapse:8008/_matrix/client/v3/sync?user_id=@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech&filter=%7B%22room%22%3A+%7B%22rooms%22%3A+%5B%22%21OMulzyGFCfueIWFHSU%3Amatrix.connectme.anais.tech%22%5D%7D%7D
-- as can be seen up, the filter is : {filter: "{"room": {"rooms": ["!OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech'"]}}"}
and the there are events under: [room id]->account_data -> events and [room id]->ephemeral -> events
http://synapse:8008/_matrix/client/v3/sync?user_id=@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech&
Homeserver
local homeserver running in a docker
Synapse Version
{"server_version":"1.61.1","python_version":"3.9.13"}
Installation Method
Docker (matrixdotorg/synapse)
Platform
docker running on Ubuntu Linux
Relevant log output
Response without a filter
https://gist.github.com/andreidiaconescu/b46175c38a05e705187d00195a548f04
Response with filter {filter: "{"room": {"rooms": ["!OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech'"]}}"}
Anything else that would be useful to know?
No response
The text was updated successfully, but these errors were encountered: