matrix-org / matrix-org/matrix-js-sdk

MatrixEvent.getRoomId() can return undefined

Open
#2,035 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.2k
Forks
704
Avg merge
1d 20h
Merged PRs (30d)
40

Description

I've lost some hours trusting the TypeScript annotation.

The return type should say `string|undefined`.

https://github.com/matrix-org/matrix-js-sdk/blob/67b8da719f6548be32c633cc28afecdf3dbabc5e/src/models/event.ts#L350-L356

btw. I didn't get this on a `m.presence` but on a `m.bad.encrypted`:

```
MatrixEvent {
_events: [Object: null prototype] {
'Event.decrypted': [ [Function: forSource], [Function] ],
'Event.replaced': [Function: forSource]
},
_eventsCount: 2,
_maxListeners: undefined,
event: {
content: {
algorithm: 'm.olm.v1.curve25519-aes-sha2',
sender_key: '8LgWTZ5yFIawz80ylkAl1Mc9BX1oUZGAAAl3z0E7lXM',
ciphertext: [Object]
},
type: 'm.room.encrypted',
sender: '@jaller94:localhost'
},
pushActions: { notify: true, tweaks: { highlight: false } },
_replacingEvent: null,
_localRedactionEvent: null,
_isCancelled: false,
clearEvent: {
type: 'm.room.message',
content: {
msgtype: 'm.bad.encrypted',
body: '** Unable to decrypt: Not included in recipients **'
}
},
senderCurve25519Key: null,
claimedEd25519Key: null,
forwardingCurve25519KeyChain: [],
untrusted: false,
_decryptionPromise: null,
retryDecryption: false,
txnId: null,
thread: null,
localTimestamp: NaN,
sender: null,
target: null,
status: null,
error: null,
forwardLooking: true,
verificationRequest: null,
reEmitter: ReEmitter { target: [Circular *1] },
[Symbol(kCapture)]: false
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/models/event.ts around lines 350-356 and inspect MatrixEvent.getRoomId(). Confirm how the method behaves for events without a room ID, including the m.bad.encrypted example. The work is done when the TypeScript return annotation accurately allows an absent value.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.