[BUG] POST /api/v1/custom-user-status.update silently overwrites statusType with empty string when omitted
Maintainers usually reply within 1 day
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
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
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:
- Create a custom user status with a presence indicator (e.g.
name: "Supriyo",statusType: "busy"). - Confirm the presence indicator shows as
busyin the UI table (/admin/user-status). - Send a
POSTrequest to/api/v1/custom-user-status.updateto update only the name, omittingstatusType:{ "_id": "6aef44df9bb283fd2954335f", "name": "Supriyo" } - Query
/api/v1/custom-user-status.listor 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"):
2. API Request (omitting statusType):
3. Server Response (statusType is wiped to empty string):
4. After Update (UI Table presence is completely wiped):
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
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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.
More from RocketChat/Rocket.Chat
-
Mark the empty state busy while a new search loads, like the table */}Possibly taken @aditya25bcy10173-a11y claimed this 2 days ago. Opentodo type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
RocketChat/Rocket.Chat#43699 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Timestamp with a time but no timezone shows as 1 January 1970Possibly taken @Sarthak-agrawal-tech claimed this 4 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat#43637 · 6 comments ·
Maintainers usually reply within 1 day
-
Move this mapping from useQuery's old `select` into a usePaginatedQuery `combine`Possibly taken @aditya25bcy10173-a11y claimed this 3 days ago. Opentodo type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat#43609 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
evaluate switching to the other tab when the selected tab's permission is revoked mid-sessionPossibly taken @schizophrenicmaniac claimed this 4 days ago. Opentodo type: feature
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RocketChat/Rocket.Chat#43579 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Docs say packages can be installed with `npm` but use unsupported `patch:` URLPossibly taken A pull request linked to this issue is open or already merged. Opentype: bug
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat#43554 · 4 comments ·
Maintainers usually reply within 1 day
All issues in RocketChat/Rocket.Chat
Similar issues
-
bug
Difficulty 2/5 Half a day Newbie friendliness 68/100
amosblomqvist/learnharness#758 ·
Maintainers usually reply within 2 days
-
Change WorkspacesOpen
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
bitfocus/companion-module-renewedvision-propresenter-api#134 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
rcpch/digital-growth-charts-react-component-library#304 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dsh-market/dsh-market#1210 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
trustjonathan/STUDY-HUB#13 ·