[BUG] POST /api/v1/custom-user-status.update silently overwrites statusType with empty string when omitted
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- mongodb, node.js, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 46.5k
- Fork
- 14.1k
- Merge medio
- 1g 21h
- PR unite (30g)
- 381
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RocketChat/Rocket.Chat
-
Mark the empty state busy while a new search loads, like the table */}Forse già presa @aditya25bcy10173-a11y l’ha presa 2 giorni fa. Apertatodo type: feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
RocketChat/Rocket.Chat#43699 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Timestamp with a time but no timezone shows as 1 January 1970Forse già presa @Sarthak-agrawal-tech l’ha presa 4 giorni fa. Apertatype: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
RocketChat/Rocket.Chat#43637 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Move this mapping from useQuery's old `select` into a usePaginatedQuery `combine`Forse già presa @aditya25bcy10173-a11y l’ha presa 3 giorni fa. Apertatodo type: feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
RocketChat/Rocket.Chat#43609 · 4 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
evaluate switching to the other tab when the selected tab's permission is revoked mid-sessionForse già presa @schizophrenicmaniac l’ha presa 4 giorni fa. Apertatodo type: feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
RocketChat/Rocket.Chat#43579 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Docs say packages can be installed with `npm` but use unsupported `patch:` URLForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertatype: bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
RocketChat/Rocket.Chat#43554 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di RocketChat/Rocket.Chat
Issue simili
-
Bug: Broken RTL / BiDi text rendering when mixing Persian (Farsi) with English or numbersForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 2/5 Mezza giornata Idoneità per principianti 68/100
amosblomqvist/learnharness#758 ·
I maintainer di solito rispondono entro 2 giorni
-
Change WorkspacesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
bitfocus/companion-module-renewedvision-propresenter-api#134 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
rcpch/digital-growth-charts-react-component-library#304 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dsh-market/dsh-market#1210 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
trustjonathan/STUDY-HUB#13 ·