RocketChat / RocketChat/Rocket.Chat

Replace non-null assertions with proper null handling in `RealAppsEngineUIHost`

Open
#39,105 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: feature
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

RealAppsEngineUIHost.ts currently relies on multiple TypeScript non-null assertions (!) to bypass strict null checks.

While this satisfies the compiler, it introduces unsafe assumptions that may lead to runtime errors such as:

TypeError: Cannot read properties of undefined

These assertions should be replaced with proper null handling to improve runtime safety and make failure cases explicit.


Problem Areas

The file contains non-null assertions in the following contexts:

  • getUserAvatarURL(username)!
  • username! inside room members mapping
  • slugifiedName!
  • getUser()!
  • username! inside getClientUserInfo

These assume values are always defined, which may not hold true for:

  • Direct Message rooms (may not define name)
  • Members without usernames
  • Missing logged-in user
  • Undefined avatar URLs

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 in RealAppsEngineUIHost.ts and inspect the listed non-null assertions alongside the types and callers that provide those values. Define explicit behavior for missing avatars, usernames, room names, and logged-in users, then validate the changes with the repository's TypeScript checks and existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.