RocketChat / RocketChat/Rocket.Chat
[Bug] users.update endpoint overwrites existing customFields instead of merging
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description
When updating a user's profile via the users.update API endpoint, providing a customFields object causes a complete overwrite of the user's existing custom fields. This results in unintended data loss for any fields not explicitly included in the payload.
The expected behavior is a merge (patch) operation, where only the specified keys are updated, and existing keys remain untouched.
Steps to reproduce
- Enable Custom Fields in Administration -> Accounts -> Registration.
- Create two custom fields (e.g.,
roleandteam). - Set initial values for a user:
{ "role": "Developer", "team": "Red" }. - Send a POST request to
api/v1/users.updatewith the following payload (updating only one field):{ "userId": "TARGET_USER_ID", "data": { "customFields": { "team": "Blue" } } }
Contributor 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.
Research direction
Start at the users.update API endpoint and reproduce the issue using the payload in the report, with existing customFields for role and team. The fix is complete when updating team preserves role and changes only the submitted custom-field keys; verify the behavior through the endpoint reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100