Skip to content

Uncaught exception in polls: TypeError: Cannot read properties of undefined (reading 'org.matrix.msc1767.text') #968

Description

@bartoostveen

Describe the bug

When opening a poll on a version of Sable that has poll support, you can observe this error. The app entirely crashes because of an unhandled exception.

TypeError: Cannot read properties of undefined (reading 'org.matrix.msc1767.text')
    at https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:99319:45
    at jA (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:5328:156)
    at n$ (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:5959:28)
    at B$ (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:7892:90)
    at T$ (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:7590:15)
    at Y_e (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:7584:29)
    at gx (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:7574:11)
    at n7 (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:7362:83)
    at S$ (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:7407:32)
    at Qh (https://matrix.bartoostveen.nl/assets/index-Byoxqa5U.js:4722:19)

The problematic code is probably here. It is generally a good idea to not assert that certain values exist in these events, but I am not sure where exactly this is going wrong
https://github.com/SableClient/Sable/blob/dev/src/app/components/message/PollEvent.tsx

Reproduction

On Sable 1.18.3, try to open a room which contains a problematic event, and observe the crash. Example of such a problematic event:

{
  "content": {
    "org.matrix.msc1767.text": "foo bar",
    "org.matrix.msc3381.poll.start": {
      "answers": [
        {
          "id": "1",
          "org.matrix.msc1767.text": "1"
        },
        {
          "id": "2",
          "org.matrix.msc1767.text": "2"
        },
        {
          "id": "3",
          "org.matrix.msc1767.text": "3"
        },
        {
          "id": "4",
          "org.matrix.msc1767.text": "4"
        },
        {
          "id": "5",
          "org.matrix.msc1767.text": "5"
        },
        {
          "id": "6",
          "org.matrix.msc1767.text": "6"
        },
        {
          "id": "7",
          "org.matrix.msc1767.text": "7"
        },
        {
          "id": "8",
          "org.matrix.msc1767.text": "8"
        },
        {
          "id": "9",
          "org.matrix.msc1767.text": "9"
        },
        {
          "id": "10",
          "org.matrix.msc1767.text": "10"
        }
      ],
      "kind": "org.matrix.msc3381.poll.disclosed",
      "max_selections": 1,
      "question": {
        "body": "foo bar",
        "msgtype": "m.text",
        "org.matrix.msc1767.text": "foo bar"
      }
    }
  },
  "type": "org.matrix.msc3381.poll.start"
}

Expected behavior

No response

Platform and versions

1. OS: GNU/Linux 7.1.1 (NixOS Unstable)
2. Browser: Chrome 149.0.7827.114
3. Sable version: 1.18.3
4. Matrix homeserver: bartoostveen.nl (Continuwuity 0.5.10)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions