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

A filtered /sync for a specific room does not include account_data or ephemeral events in its response #13648

Open
andreidiaconescu opened this issue Aug 26, 2022 · 12 comments
Labels
A-Sync defects related to /sync O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution

Comments

@andreidiaconescu
Copy link

andreidiaconescu commented Aug 26, 2022

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

................
 account_data: {
   events: [
     {
       type: 'm.fully_read',
       content: {
         event_id: '$skAJEZAaAQ23gM2FjIZ3uSemAITPnqqNpK1bwQcaRCA'
       }
     }
   ]
 },
 ephemeral: {
   events: [
     {
       type: 'm.receipt',
       content: {
         '$skAJEZAaAQ23gM2FjIZ3uSemAITPnqqNpK1bwQcaRCA': {
           'm.read': {
             '@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech': { ts: 1661529223886 }
           }
         }
       }
     }
   ]
 },
.......................

Steps to reproduce

  • I use the /sync endpoint with and without filters as JSON;
  • If i do not specify any filter, i get many rooms, including the one with id: !OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech
    and there are events under: [room id]->account_data -> events and [room id]->ephemeral -> events
  • the request URL is: http://synapse:8008/_matrix/client/v3/sync?user_id=@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech&
  • the piece of response with the events
........
 account_data: {
   events: [
     {
       type: 'm.fully_read',
       content: {
         event_id: '$skAJEZAaAQ23gM2FjIZ3uSemAITPnqqNpK1bwQcaRCA'
       }
     }
   ]
 },
 ephemeral: {
   events: [
     {
       type: 'm.receipt',
       content: {
         '$skAJEZAaAQ23gM2FjIZ3uSemAITPnqqNpK1bwQcaRCA': {
           'm.read': {
             '@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech': { ts: 1661529223886 }
           }
         }
       }
     }
   ]
 },
.........
  • If is use a filter with only one room id (!OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech) (i do not filter by any events), 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.
    • the request url is: 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'"]}}"}
  • If i do not specify any filter, i get many rooms, including the one with id: !OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech
    and the there are events under: [room id]->account_data -> events and [room id]->ephemeral -> events
    • the request URL is: 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'"]}}"}

{
  "next_batch":"s136_2442_0_24_72_1_21_75_0",
  "account_data":{
    "events":[
      {
        "type":"m.push_rules",
        "content":{
          "global":{
            "underride":[
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.call.invite"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"sound",
                    "value":"ring"
                  },
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".m.rule.call",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"room_member_count",
                    "is":"2"
                  },
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.message"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"sound",
                    "value":"default"
                  },
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".m.rule.room_one_to_one",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"room_member_count",
                    "is":"2"
                  },
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.encrypted"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"sound",
                    "value":"default"
                  },
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".m.rule.encrypted_room_one_to_one",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.message"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".m.rule.message",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.encrypted"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".m.rule.encrypted",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"im.vector.modular.widgets"
                  },
                  {
                    "kind":"event_match",
                    "key":"content.type",
                    "pattern":"jitsi"
                  },
                  {
                    "kind":"event_match",
                    "key":"state_key",
                    "pattern":"*"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".im.vector.jitsi",
                "default":true,
                "enabled":true
              }
            ],
            "sender":[
              
            ],
            "room":[
              
            ],
            "content":[
              {
                "actions":[
                  "notify",
                  {
                    "set_tweak":"sound",
                    "value":"default"
                  },
                  {
                    "set_tweak":"highlight"
                  }
                ],
                "pattern":"crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm",
                "rule_id":".m.rule.contains_user_name",
                "default":true,
                "enabled":true
              }
            ],
            "override":[
              {
                "conditions":[
                  
                ],
                "actions":[
                  "dont_notify"
                ],
                "rule_id":".m.rule.master",
                "default":true,
                "enabled":false
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"content.msgtype",
                    "pattern":"m.notice"
                  }
                ],
                "actions":[
                  "dont_notify"
                ],
                "rule_id":".m.rule.suppress_notices",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.member"
                  },
                  {
                    "kind":"event_match",
                    "key":"content.membership",
                    "pattern":"invite"
                  },
                  {
                    "kind":"event_match",
                    "key":"state_key",
                    "pattern":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"sound",
                    "value":"default"
                  },
                  {
                    "set_tweak":"highlight",
                    "value":false
                  }
                ],
                "rule_id":".m.rule.invite_for_me",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.member"
                  }
                ],
                "actions":[
                  "dont_notify"
                ],
                "rule_id":".m.rule.member_event",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"contains_display_name"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"sound",
                    "value":"default"
                  },
                  {
                    "set_tweak":"highlight"
                  }
                ],
                "rule_id":".m.rule.contains_display_name",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"content.body",
                    "pattern":"@room"
                  },
                  {
                    "kind":"sender_notification_permission",
                    "key":"room"
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"highlight",
                    "value":true
                  }
                ],
                "rule_id":".m.rule.roomnotif",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.room.tombstone"
                  },
                  {
                    "kind":"event_match",
                    "key":"state_key",
                    "pattern":""
                  }
                ],
                "actions":[
                  "notify",
                  {
                    "set_tweak":"highlight",
                    "value":true
                  }
                ],
                "rule_id":".m.rule.tombstone",
                "default":true,
                "enabled":true
              },
              {
                "conditions":[
                  {
                    "kind":"event_match",
                    "key":"type",
                    "pattern":"m.reaction"
                  }
                ],
                "actions":[
                  "dont_notify"
                ],
                "rule_id":".m.rule.reaction",
                "default":true,
                "enabled":true
              }
            ]
          },
          "device":{
            
          }
        }
      }
    ]
  },
  "presence":{
    "events":[
      {
        "type":"m.presence",
        "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
        "content":{
          "presence":"online",
          "last_active_ago":37,
          "currently_active":true
        }
      }
    ]
  },
  "device_one_time_keys_count":{
    
  },
  "org.matrix.msc2732.device_unused_fallback_key_types":[
    
  ],
  "device_unused_fallback_key_types":[
    
  ],
  "rooms":{
    "join":{
      "!OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech":{
        "timeline":{
          "events":[
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661353300788,
              "unsigned":{
                "age":419138411
              },
              "event_id":"$5SLph75AE_NlYojaCPh80yXW3vGBR3vbTVJO1592_7I"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 24.7",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661360177972,
              "unsigned":{
                "age":412261227
              },
              "event_id":"$Xl3EFDQ5D5s8k6Q0vSYoPXJLln8MZXRZvAdLT9QIs-0"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 24.8",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661360539946,
              "unsigned":{
                "age":411899253
              },
              "event_id":"$E_Gy6NRH2zHrWJOSq-KgC9wGLp14jzBhlvMw39kYVUc"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 24.8",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661360571035,
              "unsigned":{
                "age":411868164
              },
              "event_id":"$_RM0GT5oAdb-_TNuL6GHg6neT9a8_-82jIHYSEzQAXI"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 3",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661421183313,
              "unsigned":{
                "age":351255886
              },
              "event_id":"$iSCyyjTpwp8PrY_2GUMjejK8q8g60lHxogswUykbDSU"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661503759353,
              "unsigned":{
                "age":268679846
              },
              "event_id":"$AgMg-6S9u68yYVOXLptsTrR9QVgbL40Eksr6FLkzA9o"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 2",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661529143156,
              "unsigned":{
                "age":243296043
              },
              "event_id":"$Y-10cPukMqWiNFikUKwZjIUBd5wSi_RXduMB3ovObbI"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 2",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661529148703,
              "unsigned":{
                "age":243290496
              },
              "event_id":"$srIBdPtwSweeGET8zwxfRcyhR1gTcKeyRXpG642lKrg"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 2",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661529149614,
              "unsigned":{
                "age":243289585
              },
              "event_id":"$IGqxKjzFlKkRg5vMA_imwCHspdwJXRuPoK1PUCOkzSM"
            },
            {
              "type":"m.room.message",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "body":"Hello room 2",
                "msgtype":"m.text"
              },
              "origin_server_ts":1661529150251,
              "unsigned":{
                "age":243288948
              },
              "event_id":"$skAJEZAaAQ23gM2FjIZ3uSemAITPnqqNpK1bwQcaRCA"
            }
          ],
          "prev_batch":"t17-106_2442_0_24_72_1_21_75_0",
          "limited":true
        },
        "state":{
          "events":[
            {
              "type":"m.room.create",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "m.federate":false,
                "room_version":"9",
                "creator":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech"
              },
              "state_key":"",
              "origin_server_ts":1660219601960,
              "unsigned":{
                "age":1552837239
              },
              "event_id":"$wr35Gm95Q6LgM2L_jPxoWiO7mtfklVNYlDDRcbD4RiM"
            },
            {
              "type":"m.room.name",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "name":"Some room name"
              },
              "state_key":"",
              "origin_server_ts":1660219602183,
              "unsigned":{
                "age":1552837016
              },
              "event_id":"$LTBe7APFJMfEEcIUFBtilu-4PL1L66xQYdRiArnAg2U"
            },
            {
              "type":"m.room.join_rules",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "join_rule":"public"
              },
              "state_key":"",
              "origin_server_ts":1660219602118,
              "unsigned":{
                "age":1552837081
              },
              "event_id":"$fS0QQt0TvblYeXVi2TW6zO4HNoJvKFrsgqxiaM3uHt8"
            },
            {
              "type":"m.room.topic",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "topic":"Topic Some room name"
              },
              "state_key":"",
              "origin_server_ts":1660219602221,
              "unsigned":{
                "age":1552836978
              },
              "event_id":"$ofhgZ9QSXObvuZw_0YqvK710N5HG7ZPR9C88Wy0mV7Y"
            },
            {
              "type":"m.room.history_visibility",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "history_visibility":"shared"
              },
              "state_key":"",
              "origin_server_ts":1660219602146,
              "unsigned":{
                "age":1552837053
              },
              "event_id":"$Cy7gVU0kCYYlXVS27y2Db25IV2Ex5K65r-8f7uWNr_4"
            },
            {
              "type":"m.room.member",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "reason":"To chat",
                "membership":"join",
                "displayname":"gabriel@coppensint.com"
              },
              "state_key":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "origin_server_ts":1660298502509,
              "unsigned":{
                "replaces_state":"$Nckx1e1IxHheJ2ltriLMDcDnZ-Gme0dHPloLcdOgI4k",
                "prev_content":{
                  "membership":"join",
                  "displayname":"gabriel@coppensint.com"
                },
                "prev_sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
                "age":1473936690
              },
              "event_id":"$pgmOvJgxLVlrpowij15O3QOLB3KE0qh-SPIbW-zXfIA"
            },
            {
              "type":"m.room.canonical_alias",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "alias":"#Some_room_alias:matrix.connectme.anais.tech"
              },
              "state_key":"",
              "origin_server_ts":1660219602086,
              "unsigned":{
                "age":1552837113
              },
              "event_id":"$qodvjctcZ6mEMh_3UKHugpXL8LAxvoidoBokrQY7uIU"
            },
            {
              "type":"m.room.power_levels",
              "sender":"@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech",
              "content":{
                "users":{
                  "@crx66ctg69h32rv55mr3gd1n5mu3arb25nh3ce325ngk0ctn60up4c1h6hhk2ek7c5h74ub5dh066vvge1jpwwv9dtu2wrvfdm:matrix.connectme.anais.tech":100
                },
                "users_default":0,
                "events":{
                  "m.room.name":50,
                  "m.room.power_levels":100,
                  "m.room.history_visibility":100,
                  "m.room.canonical_alias":50,
                  "m.room.avatar":50,
                  "m.room.tombstone":100,
                  "m.room.server_acl":100,
                  "m.room.encryption":100
                },
                "events_default":0,
                "state_default":50,
                "ban":50,
                "kick":50,
                "redact":50,
                "invite":50,
                "historical":100
              },
              "state_key":"",
              "origin_server_ts":1660219602047,
              "unsigned":{
                "age":1552837152
              },
              "event_id":"$I5fQTJJYV55XZMzk0e0EUEwhteW4s1DRWWrGO6cvCaU"
            }
          ]
        },
        "account_data":{
          "events":[
            
          ]
        },
        "ephemeral":{
          "events":[
            
          ]
        },
        "unread_notifications":{
          "notification_count":0,
          "highlight_count":0
        },
        "summary":{
          
        }
      }
    }
  }
}

Anything else that would be useful to know?

No response

@andreidiaconescu andreidiaconescu changed the title /sync filtering by room seems to truncate data of desired room /sync filtering by room seems to miss data of desired room, which is not missing when no filtering is used Aug 26, 2022
@andreidiaconescu
Copy link
Author

this looks like a bug.
any help on this please ?

@andreidiaconescu andreidiaconescu changed the title /sync filtering by room seems to miss data of desired room, which is not missing when no filtering is used /sync filtering by room only, misses data of that room, which is not missing in same room when no filtering is used Aug 29, 2022
@andreidiaconescu andreidiaconescu changed the title /sync filtering by room only, misses data of that room, which is not missing in same room when no filtering is used /sync filtering by room only, misses data of that room, which is not missing from same room when no filtering is used Aug 29, 2022
@andreidiaconescu
Copy link
Author

hello,
any guidance on this please ?

@andreidiaconescu andreidiaconescu changed the title /sync filtering by room only, misses data of that room, which is not missing from same room when no filtering is used /sync filtering by room only, misses some of the data of that room, which is not missing from same room when no filtering is used Aug 30, 2022
@DMRobertson
Copy link
Contributor

DMRobertson commented Aug 30, 2022

To summarise the report: the filter

{filter: "{"room": {"rooms": ["!OMulzyGFCfueIWFHSU:matrix.connectme.anais.tech'"]}}"}

only includes timeline events for that room in the /sync response. It does not include account_data or ephemeral events.

@DMRobertson DMRobertson changed the title /sync filtering by room only, misses some of the data of that room, which is not missing from same room when no filtering is used A filtered /sync for a specific room does not include account_data or ephemeral events in the response Aug 30, 2022
@DMRobertson DMRobertson changed the title A filtered /sync for a specific room does not include account_data or ephemeral events in the response A filtered /sync for a specific room does not include account_data or ephemeral events in its response Aug 30, 2022
@DMRobertson DMRobertson added A-Sync defects related to /sync S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Aug 30, 2022
@Zocker1999NET
Copy link

@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

@andreidiaconescu
Copy link
Author

@Zocker1999NET done, i hope it's ok.

@DMRobertson
Copy link
Contributor

{"server_version":"1.61.1","python_version":"3.9.13"}

Sanity check: do you see this when running against the latest version of Synapse (1.65)?

@DMRobertson
Copy link
Contributor

DMRobertson commented Aug 30, 2022

I seem to be able to reproduce this on matrix.org:

$ curl -H "Authorization: Bearer $TOKEN" --get https://matrix-client.matrix.org/_matrix/client/v3/sync --data-urlencode 'filter={"room": {"rooms": ["!SGNQGPGUwtcPBUotTL:matrix.org"]}}' | tee response-filter | jq '.rooms.join."!SGNQGPGUwtcPBUotTL:matrix.org".account_data.events | length'
0

$ curl -H "Authorization: Bearer $TOKEN" --get https://matrix-client.matrix.org/_matrix/client/v3/sync | tee response-no-filter | jq '.rooms.join."!SGNQGPGUwtcPBUotTL:matrix.org".account_data.events | length'
2

@DMRobertson
Copy link
Contributor

I've narrowed this down to here

account_data_events = (
await sync_config.filter_collection.filter_room_account_data(
account_data_events
)
)

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.

@DMRobertson
Copy link
Contributor

The call to self._room_filter.filter(events) here removes the given events.

async def filter_room_account_data(
self, events: Iterable[JsonDict]
) -> List[JsonDict]:
return await self._room_account_data.filter(
await self._room_filter.filter(events)
)

Has this been broken for ages?

@DMRobertson
Copy link
Contributor

DMRobertson commented Aug 30, 2022

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 room checks too. So we are going to be looking for a room_id on the account data event itself. This field doesn't exist and so the filter excludes the account data event.

This is an example where Matrix sloppily calls all sorts of JSON objects events without formally distinguishing between their semantics and expected structure.

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.

@DMRobertson DMRobertson added the Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution label Aug 30, 2022
@DMRobertson
Copy link
Contributor

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):
 

@josegoval
Copy link

Is there any possibility this get a fix?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Sync defects related to /sync O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution
Projects
None yet
Development

No branches or pull requests

4 participants