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

オープン
#43,591 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Supriyo760 がすでに取り組んでいます。

2026年11月7日 から。

  • #43592 @Supriyo760 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
mongodb, node.js, typescript
領域
api, backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
TypeScript
スター
46.5k
フォーク
14.1k
平均マージ
1日 21時間
マージ済み PR(30日)
381

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RocketChat/Rocket.Chat のほかの issue

RocketChat/Rocket.Chat の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。