matrix-org / matrix-org/matrix-js-sdk
MatrixEvent.getRoomId() can return undefined
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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