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

Thread bundled relationships can return a split-brained latest_event #12270

Closed
t3chguy opened this issue Mar 23, 2022 · 3 comments · Fixed by #12273
Closed

Thread bundled relationships can return a split-brained latest_event #12270

t3chguy opened this issue Mar 23, 2022 · 3 comments · Fixed by #12273
Assignees
Labels
A-Threads Threaded messages S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@t3chguy
Copy link
Member

t3chguy commented Mar 23, 2022

Description

The latest_event returned in an m.thread bundled relationship can be split-brained if it was edited, the content got updated but the m.replace relation is not signalled in any way, which means clients now have to manually fetch the relations on the latest_event to check whether it was edited or not.

/event/ call on the thread root await mxMatrixClientPeg.matrixClient.fetchRoomEvent("!cCpRBTFuXwPmOCUFRL:matrix.org", "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ")

{
  "content": {
    "body": "root",
    "msgtype": "m.text",
    "org.matrix.msc1767.text": "root"
  },
  "origin_server_ts": 1647960269875,
  "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
  "sender": "@webdevguru_test31:matrix.org",
  "type": "m.room.message",
  "unsigned": {
    "age": 66278821,
    "m.relations": {
      "m.thread": {
        "latest_event": {
          "content": {
            "body": "testfoobar",
            "format": "org.matrix.custom.html",
            "formatted_body": "testfoobar",
            "msgtype": "m.text",
            "org.matrix.msc1767.message": [
              {
                "body": "testfoobar",
                "mimetype": "text/plain"
              },
              {
                "body": "testfoobar",
                "mimetype": "text/html"
              }
            ],
            "m.relates_to": {
              "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
              "is_falling_back": true,
              "m.in_reply_to": {
                "event_id": "$6WWJ7Hga3ZtlTehlThl-v2_doVAFs5EaqgCoffLM9gc"
              },
              "rel_type": "m.thread"
            }
          },
          "origin_server_ts": 1648024628463,
          "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
          "sender": "@webdevguru_test31:matrix.org",
          "type": "m.room.message",
          "unsigned": {
            "age": 1920233
          },
          "event_id": "$e8ENHc50vigxQU3NgeZ6I5A68dL1IGqouonJb500jpk",
          "user_id": "@webdevguru_test31:matrix.org",
          "age": 1920233
        },
        "count": 7,
        "current_user_participated": true
      }
    }
  },
  "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
  "user_id": "@webdevguru_test31:matrix.org",
  "age": 66278821
}

/event/ call on the latest event in the thread await mxMatrixClientPeg.matrixClient.fetchRoomEvent("!cCpRBTFuXwPmOCUFRL:matrix.org", "$e8ENHc50vigxQU3NgeZ6I5A68dL1IGqouonJb500jpk")

{
  "content": {
    "body": "testfoobar",
    "format": "org.matrix.custom.html",
    "formatted_body": "testfoobar",
    "msgtype": "m.text",
    "org.matrix.msc1767.message": [
      {
        "body": "testfoobar",
        "mimetype": "text/plain"
      },
      {
        "body": "testfoobar",
        "mimetype": "text/html"
      }
    ],
    "m.relates_to": {
      "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
      "is_falling_back": true,
      "m.in_reply_to": {
        "event_id": "$6WWJ7Hga3ZtlTehlThl-v2_doVAFs5EaqgCoffLM9gc"
      },
      "rel_type": "m.thread"
    }
  },
  "origin_server_ts": 1648024628463,
  "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
  "sender": "@webdevguru_test31:matrix.org",
  "type": "m.room.message",
  "unsigned": {
    "age": 1940276,
    "m.relations": {
      "m.replace": {
        "event_id": "$8fzcKK9FohMXMGhvGM13dYoLM1S6Ekgw8Oz2ojW2dl8",
        "origin_server_ts": 1648025699050,
        "sender": "@webdevguru_test31:matrix.org"
      }
    }
  },
  "event_id": "$e8ENHc50vigxQU3NgeZ6I5A68dL1IGqouonJb500jpk",
  "user_id": "@webdevguru_test31:matrix.org",
  "age": 1940276
}

Observe the event ID and content are the same, but the latter includes the m.replace relation which should be sanely returned in the first request also.

Steps to reproduce

  • Create a thread with root $root
  • Reply to thread $root with event $event (content A)
  • Edit event $event with event $edit (content B)
  • Ask the server for $root via /event/ API and receive latest_event $event with content B and no details about m.replace or $edit

I would have expected latest_event to either be entirely unedited or edited with the relation.

Version information

matrix.org

@t3chguy
Copy link
Member Author

t3chguy commented Mar 23, 2022

The relations API correctly returns the expected data here

{
  "chunk": [
    {
      "content": {
        "body": "testfoobar1",
        "format": "org.matrix.custom.html",
        "formatted_body": "testfoobar1",
        "msgtype": "m.text",
        "org.matrix.msc1767.message": [
          {
            "body": "testfoobar1",
            "mimetype": "text/plain"
          },
          {
            "body": "testfoobar1",
            "mimetype": "text/html"
          }
        ],
        "m.relates_to": {
          "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
          "is_falling_back": true,
          "m.in_reply_to": {
            "event_id": "$6WWJ7Hga3ZtlTehlThl-v2_doVAFs5EaqgCoffLM9gc"
          },
          "rel_type": "m.thread"
        }
      },
      "origin_server_ts": 1648024628463,
      "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
      "sender": "@webdevguru_test31:matrix.org",
      "type": "m.room.message",
      "unsigned": {
        "age": 5181292,
        "m.relations": {
          "m.replace": {
            "event_id": "$S8TYTeiuN7aztAIOvVRRq-yE5bi36XmXJ1cZD2MQaAw",
            "origin_server_ts": 1648028879518,
            "sender": "@webdevguru_test31:matrix.org"
          }
        }
      },
      "event_id": "$e8ENHc50vigxQU3NgeZ6I5A68dL1IGqouonJb500jpk",
      "user_id": "@webdevguru_test31:matrix.org",
      "age": 5181292
    },
    {
      "content": {
        "body": "578",
        "format": "org.matrix.custom.html",
        "formatted_body": "578",
        "msgtype": "m.text",
        "org.matrix.msc1767.message": [
          {
            "body": "578",
            "mimetype": "text/plain"
          },
          {
            "body": "578",
            "mimetype": "text/html"
          }
        ],
        "m.relates_to": {
          "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
          "is_falling_back": true,
          "m.in_reply_to": {
            "event_id": "$0t3DFsi2AcLsaNoOWmABioDQfRviL_lX2jEMK3jV1vI"
          },
          "rel_type": "m.thread"
        }
      },
      "origin_server_ts": 1648024407578,
      "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
      "sender": "@webdevguru_test31:matrix.org",
      "type": "m.room.message",
      "unsigned": {
        "age": 5402177,
        "m.relations": {
          "m.replace": {
            "event_id": "$zE3_wtcVjdVBzBRVycEBWu5MvuyuOM8P7MmA1C8WFEs",
            "origin_server_ts": 1648024533680,
            "sender": "@webdevguru_test31:matrix.org"
          }
        }
      },
      "event_id": "$6WWJ7Hga3ZtlTehlThl-v2_doVAFs5EaqgCoffLM9gc",
      "user_id": "@webdevguru_test31:matrix.org",
      "age": 5402177
    },
    {
      "content": {
        "body": "45",
        "format": "org.matrix.custom.html",
        "formatted_body": "45",
        "msgtype": "m.text",
        "org.matrix.msc1767.message": [
          {
            "body": "45",
            "mimetype": "text/plain"
          },
          {
            "body": "45",
            "mimetype": "text/html"
          }
        ],
        "m.relates_to": {
          "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
          "is_falling_back": true,
          "m.in_reply_to": {
            "event_id": "$fMyeT873xDGthUi_muAtmyb7retSUsjE8C6hXTT-dKY"
          },
          "rel_type": "m.thread"
        }
      },
      "origin_server_ts": 1648024169964,
      "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
      "sender": "@webdevguru_test31:matrix.org",
      "type": "m.room.message",
      "unsigned": {
        "age": 5639791,
        "m.relations": {
          "m.replace": {
            "event_id": "$12Rnowgxo2Nq6LU8osif1c6efs142nSH2jTB-63q46w",
            "origin_server_ts": 1648024171546,
            "sender": "@webdevguru_test31:matrix.org"
          }
        }
      },
      "event_id": "$0t3DFsi2AcLsaNoOWmABioDQfRviL_lX2jEMK3jV1vI",
      "user_id": "@webdevguru_test31:matrix.org",
      "age": 5639791
    },
    {
      "content": {
        "body": "123",
        "m.relates_to": {
          "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
          "is_falling_back": true,
          "m.in_reply_to": {
            "event_id": "$x_AcYE4IMA7ecOO2Ewqn-PtsDeNZzEM02ZiMyat1IpI"
          },
          "rel_type": "m.thread"
        },
        "msgtype": "m.text",
        "org.matrix.msc1767.text": "123"
      },
      "origin_server_ts": 1648024168073,
      "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
      "sender": "@webdevguru_test31:matrix.org",
      "type": "m.room.message",
      "unsigned": {
        "age": 5641682
      },
      "event_id": "$fMyeT873xDGthUi_muAtmyb7retSUsjE8C6hXTT-dKY",
      "user_id": "@webdevguru_test31:matrix.org",
      "age": 5641682
    },
    {
      "content": {
        "body": "1234",
        "format": "org.matrix.custom.html",
        "formatted_body": "1234",
        "msgtype": "m.text",
        "org.matrix.msc1767.message": [
          {
            "body": "1234",
            "mimetype": "text/plain"
          },
          {
            "body": "1234",
            "mimetype": "text/html"
          }
        ],
        "m.relates_to": {
          "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
          "is_falling_back": true,
          "m.in_reply_to": {
            "event_id": "$UCY9RizsSWxNJxiWKJrvZ-V0PC6RA0ecHc31rNRoeTU"
          },
          "rel_type": "m.thread"
        }
      },
      "origin_server_ts": 1648022929064,
      "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
      "sender": "@webdevguru_test31:matrix.org",
      "type": "m.room.message",
      "unsigned": {
        "age": 6880691,
        "m.relations": {
          "m.replace": {
            "event_id": "$hE9X0x0kBFmjP1dTBk0ltFQ-wer4RXt4x2smE4QUw0E",
            "origin_server_ts": 1648022972081,
            "sender": "@webdevguru_test31:matrix.org"
          }
        }
      },
      "event_id": "$x_AcYE4IMA7ecOO2Ewqn-PtsDeNZzEM02ZiMyat1IpI",
      "user_id": "@webdevguru_test31:matrix.org",
      "age": 6880691
    }
  ],
  "next_batch": "t62-2793387561_0_0_0_0_0_0_0_0",
  "original_event": {
    "content": {
      "body": "root",
      "msgtype": "m.text",
      "org.matrix.msc1767.text": "root"
    },
    "origin_server_ts": 1647960269875,
    "room_id": "!cCpRBTFuXwPmOCUFRL:matrix.org",
    "sender": "@webdevguru_test31:matrix.org",
    "type": "m.room.message",
    "unsigned": {
      "age": 69539880
    },
    "event_id": "$2fQ-tX_N6eXHllDPHN3gYD_2ghfbZkGfjvjQdUqxtFQ",
    "user_id": "@webdevguru_test31:matrix.org",
    "age": 69539880
  }
}

@clokep
Copy link
Member

clokep commented Mar 23, 2022

We don't bundle any relations for the latest event, we should be able to inject that the edit occurred though.

@clokep clokep added the T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. label Mar 23, 2022
@clokep clokep self-assigned this Mar 23, 2022
@clokep clokep added A-Threads Threaded messages S-Minor Blocks non-critical functionality, workarounds exist. labels Mar 23, 2022
@clokep
Copy link
Member

clokep commented Mar 23, 2022

#12273 should fix this so that all bundled aggregations are included in the latest threaded event.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Threads Threaded messages S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants