RocketChat / RocketChat/Rocket.Chat

[Bug] users.update endpoint overwrites existing customFields instead of merging

Open
#37,993 2 comments 1 reaction 0 assignees View on GitHub

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
  1. Enable Custom Fields in Administration -> Accounts -> Registration.
  2. Create two custom fields (e.g., role and team).
  3. Set initial values for a user: { "role": "Developer", "team": "Red" }.
  4. Send a POST request to api/v1/users.update with the following payload (updating only one field):
    {
      "userId": "TARGET_USER_ID",
      "data": { "customFields": { "team": "Blue" } }
    }

Contributor guide

Open the contributing guide

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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.