Skip to content

Conversation

@cardoso
Copy link
Member

@cardoso cardoso commented Jul 30, 2025

Proposed changes (including videos or screenshots)

This PR fixes a bug where the /api/v1/users.update API call was replacing the entire customFields object instead of merging only the specified properties. The fix ensures that when updating custom fields, existing values are preserved while only specified fields are updated or added.

Key changes:

  • Modified the custom fields saving logic to use field-specific updates instead of replacing the entire object
  • Added comprehensive test coverage for both API endpoints and UI interactions
  • Updated the field-saving function to filter out undefined values and use MongoDB's dot notation for field updates
Show a summary per file
File Description
apps/meteor/app/lib/server/functions/saveCustomFieldsWithoutValidation.ts Core fix - changes from replacing entire customFields object to updating individual fields using dot notation
apps/meteor/tests/end-to-end/api/users.ts API test coverage for custom fields merging behavior
apps/meteor/tests/e2e/admin-users-custom-fields.spec.ts End-to-end UI test coverage for admin user custom field management
apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-users.ts Page object updates to support custom field testing
.changeset/wild-kiwis-cover.md Changeset documentation for the bug fix

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-1260

Steps to test or reproduce

Further comments

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jul 30, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@cardoso cardoso marked this pull request as draft July 30, 2025 21:10
@changeset-bot
Copy link

changeset-bot bot commented Jul 30, 2025

🦋 Changeset detected

Latest commit: 81716b7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 39 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/omni-core-ee Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cardoso cardoso added this to the 7.10.0 milestone Jul 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 30, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-36578/

Built to branch gh-pages at 2025-08-02 16:11 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.68%. Comparing base (1142862) to head (81716b7).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #36578      +/-   ##
===========================================
- Coverage    65.69%   65.68%   -0.01%     
===========================================
  Files         3195     3195              
  Lines       106739   106739              
  Branches     20321    20370      +49     
===========================================
- Hits         70122    70114       -8     
- Misses       33979    33986       +7     
- Partials      2638     2639       +1     
Flag Coverage Δ
e2e 56.96% <ø> (+0.02%) ⬆️
unit 71.25% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cardoso cardoso requested a review from Copilot July 31, 2025 12:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the /api/v1/users.update API call was replacing the entire customFields object instead of merging only the specified properties. The fix ensures that when updating custom fields, existing values are preserved while only specified fields are updated or added.

Key changes:

  • Modified the custom fields saving logic to use field-specific updates instead of replacing the entire object
  • Added comprehensive test coverage for both API endpoints and UI interactions
  • Updated the field-saving function to filter out undefined values and use MongoDB's dot notation for field updates

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/meteor/app/lib/server/functions/saveCustomFieldsWithoutValidation.ts Core fix - changes from replacing entire customFields object to updating individual fields using dot notation
apps/meteor/tests/end-to-end/api/users.ts API test coverage for custom fields merging behavior
apps/meteor/tests/e2e/admin-users-custom-fields.spec.ts End-to-end UI test coverage for admin user custom field management
apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-users.ts Page object updates to support custom field testing
.changeset/wild-kiwis-cover.md Changeset documentation for the bug fix

@cardoso cardoso marked this pull request as ready for review July 31, 2025 12:31
@cardoso cardoso requested review from a team as code owners July 31, 2025 12:31
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include an additional test ensuring that if the admin removes a custom field's value (aka change it to an empty string), it gets successfully removed from the user too.

@cardoso cardoso requested a review from pierre-lehnen-rc July 31, 2025 18:27
@cardoso
Copy link
Member Author

cardoso commented Aug 4, 2025

/patch

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Pull request #36612 added to Project: "Patch 7.9.1"

@scuciatto
Copy link
Member

/backport 7.8.4

dionisio-bot bot pushed a commit that referenced this pull request Aug 4, 2025
Co-authored-by: Jessica Schelly Souza <jessica_schelly@hotmail.com>
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Pull request #36613 added to Project: "Patch 7.8.4"

@scuciatto
Copy link
Member

/backport 7.7.8

dionisio-bot bot pushed a commit that referenced this pull request Aug 4, 2025
Co-authored-by: Jessica Schelly Souza <jessica_schelly@hotmail.com>
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Pull request #36614 added to Project: "Patch 7.7.8"

@scuciatto
Copy link
Member

/backport 7.6.5

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Sorry, I couldn't do that backport because of conflicts. Could you please solve them?

you can do so by running the following commands:

git fetch
git checkout backport-7.6.5-36578
git cherry-pick 57c6a3a1cf9c0cdc643bc955a3093948f42f01fc
// solve the conflict
git push

after that just run /backport 7.6.5 again

@scuciatto
Copy link
Member

/backport 7.5.4

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Sorry, I couldn't do that backport because of conflicts. Could you please solve them?

you can do so by running the following commands:

git fetch
git checkout backport-7.5.4-36578
git cherry-pick 57c6a3a1cf9c0cdc643bc955a3093948f42f01fc
// solve the conflict
git push

after that just run /backport 7.5.4 again

@scuciatto
Copy link
Member

/backport 7.4.5

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Sorry, I couldn't do that backport because of conflicts. Could you please solve them?

you can do so by running the following commands:

git fetch
git checkout backport-7.4.5-36578
git cherry-pick 57c6a3a1cf9c0cdc643bc955a3093948f42f01fc
// solve the conflict
git push

after that just run /backport 7.4.5 again

cardoso added a commit that referenced this pull request Aug 4, 2025
Co-authored-by: Jessica Schelly Souza <jessica_schelly@hotmail.com>
@cardoso
Copy link
Member Author

cardoso commented Aug 4, 2025

/backport 7.6.5

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Pull request #36615 added to Project: "Patch 7.6.5"

cardoso added a commit that referenced this pull request Aug 4, 2025
Co-authored-by: Jessica Schelly Souza <jessica_schelly@hotmail.com>
@cardoso
Copy link
Member Author

cardoso commented Aug 4, 2025

/backport 7.4.5

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Pull request #36616 added to Project: "Patch 7.4.5"

cardoso added a commit that referenced this pull request Aug 4, 2025
Co-authored-by: Jessica Schelly Souza <jessica_schelly@hotmail.com>
@cardoso
Copy link
Member Author

cardoso commented Aug 4, 2025

/backport 7.5.4

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 4, 2025

Pull request #36618 added to Project: "Patch 7.5.4"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants