Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Old custom fields from migrated contacts are not ignored on update #34139

Merged
merged 11 commits into from
Dec 18, 2024

Conversation

matheusbsilva137
Copy link
Member

@matheusbsilva137 matheusbsilva137 commented Dec 6, 2024

Proposed changes (including videos or screenshots)

  • On contact update, ignore custom fields that were previously in the contact, but are not registered in the workspace anymore (do not throw any error and do not change them);
  • On contact update, keep "legacy" custom fields (which are not registered in the workspace anymore) even if they are not specified in the update;

Issue(s)

Steps to test or reproduce

  1. Create an omnichannel custom field (Omnichannel > Custom fields);
  2. Create a contact using the custom field that has just been created;
  3. Delete the custom field created in step 1;
  4. Try updating the contact created in step 2 (using the UI or the contacts.update endpoint).

Current behavior: if the old custom field is provided in the update payload (this happens by default when using the UI to update the contact), then RC throws an error (caused by the unsupported custom field);
Expected behavior: no error should be thrown on update (even if the old custom field is provided). The old/legacy custom field should be kept unchanged. We should still throw an error in case extra custom fields (that are not in the contact before the update) are provided.

Further comments

SCI-193

@matheusbsilva137 matheusbsilva137 added this to the 7.2.0 milestone Dec 6, 2024
Copy link
Contributor

dionisio-bot bot commented Dec 6, 2024

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

Copy link

changeset-bot bot commented Dec 6, 2024

🦋 Changeset detected

Latest commit: d55f90b

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

This PR includes changesets to release 35 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/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts 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/network-broker Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status 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

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.81%. Comparing base (75a14b2) to head (d55f90b).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #34139   +/-   ##
========================================
  Coverage    75.81%   75.81%           
========================================
  Files          512      512           
  Lines        22205    22205           
  Branches      5403     5403           
========================================
  Hits         16834    16834           
  Misses        4720     4720           
  Partials       651      651           
Flag Coverage Δ
unit 75.81% <ø> (ø)

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

Copy link
Contributor

github-actions bot commented Dec 6, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-34139/
on branch gh-pages at 2024-12-18 07:55 UTC

@matheusbsilva137 matheusbsilva137 marked this pull request as ready for review December 6, 2024 19:42
@matheusbsilva137 matheusbsilva137 requested review from a team as code owners December 6, 2024 19:42
Copy link
Contributor

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

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

Not a fan of the destructive behavior this may cause. Wonder if it would be better to create a setting to allow users to decide if we ignore or remove the old fields.

Some users may not have the custom field registered anymore but it can hold data they want or they access via some internal api 👀

apps/meteor/tests/end-to-end/api/livechat/contacts.ts Outdated Show resolved Hide resolved
@matheusbsilva137
Copy link
Member Author

Not a fan of the destructive behavior this may cause. Wonder if it would be better to create a setting to allow users to decide if we ignore or remove the old fields.

Brought your suggestion to the product team and we decided to keep all "legacy" custom fields on update. They're not being deleted anymore
I updated all tests to follow this new behavior

@Harmeet221 Harmeet221 added the stat: QA assured Means it has been tested and approved by a company insider label Dec 18, 2024
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 18, 2024
@Harmeet221 Harmeet221 removed stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Dec 18, 2024
@Harmeet221 Harmeet221 added the stat: QA assured Means it has been tested and approved by a company insider label Dec 18, 2024
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 18, 2024
@kodiakhq kodiakhq bot merged commit 037e692 into develop Dec 18, 2024
51 checks passed
@kodiakhq kodiakhq bot deleted the fix/contacts-update-old-custom-fields branch December 18, 2024 11:41
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.

3 participants