[BUG] POST /api/v1/custom-user-status.update silently overwrites statusType with empty string when omitted

Open
#43,591 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Supriyo760 is already working on this.

Since Nov 7, 2026.

  • #43592 by @Supriyo760 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
mongodb, node.js, typescript
Domain
api, backend, databases

Research direction

Start with apps/meteor/server/api/v1/custom-user-status.ts and trace how omitted statusType reaches insertOrUpdateUserStatus.ts; inspect the update tests around this endpoint. Done means updating only the name preserves the existing presence indicator, with a regression test covering an omitted statusType.

Written by the indexing model from the issue text.

Description

type: bug
Description:

When updating a custom user status using the REST API endpoint POST /api/v1/custom-user-status.update without providing statusType (which is optional according to the endpoint schema isCustomUserStatusUpdateProps), the endpoint silently sets statusType to an empty string "" in MongoDB, permanently erasing the user status presence indicator.

Steps to reproduce:
  1. Create a custom user status with a presence indicator (e.g. name: "Supriyo", statusType: "busy").
  2. Confirm the presence indicator shows as busy in the UI table (/admin/user-status).
  3. Send a POST request to /api/v1/custom-user-status.update to update only the name, omitting statusType:
    {
      "_id": "6aef44df9bb283fd2954335f",
      "name": "Supriyo"
    }
    
  4. Query /api/v1/custom-user-status.list or view the Administration -> User status page.
Expected behavior:

The existing statusType ("busy") should be preserved when statusType is not provided in the update payload.

Actual behavior:

statusType is overwritten with "" (empty string) in MongoDB, causing permanent data loss. The presence indicator badge disappears completely from the UI table.

Visual Evidence:

1. Before Update (UI Table shows "busy"):

Image

2. API Request (omitting statusType):

Image

3. Server Response (statusType is wiped to empty string):

Image

4. After Update (UI Table presence is completely wiped):

Image
Server Setup Information:
  • Version of Rocket.Chat Server: 8.9.1 / 9.1.0-develop
  • License Type: Community
  • Number of Users: 1
  • Operating System: Windows / Linux
  • Deployment Method: docker / source
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: 24.x
  • MongoDB Version: 8.0
Client Setup Information
  • Desktop App or Browser Version: Chrome
  • Operating System: Windows 11
Additional context

Root Cause:
In apps/meteor/server/api/v1/custom-user-status.ts (line 233):

const userStatusData = {
    _id: this.bodyParams._id,
    name: this.bodyParams.name,
    statusType: this.bodyParams.statusType || '', // <-- Defaults undefined to ''
};

Because this.bodyParams.statusType is undefined, it evaluates to ''. Then in insertOrUpdateUserStatus.ts (line 83):

if (userStatusData.statusType !== userStatusData.previousStatusType) {
    await CustomUserStatus.setStatusType(userStatusData._id, userStatusData.statusType);
}

userStatusData.previousStatusType is never passed from the endpoint (undefined), so '' !== undefined evaluates to true, and MongoDB writes statusType: '' over the existing record.

I have a fix ready with automated end-to-end test cases and would love to open a PR for this.

Dominant language
TypeScript
Stars
46.5k
Forks
14.1k
Avg merge
1d 21h
Merged PRs (30d)
381

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from RocketChat/Rocket.Chat

All issues in RocketChat/Rocket.Chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.