1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

fix: env variants event changelog (#4712)

https://linear.app/unleash/issue/2-1397/fix-environment-variants-change-event-does-not-include-changelogs

By running `applyPatch` without cloning the `oldVariants`, `applyPatch`
would patch the `oldVariants` by reference, effectively making them the
same as the `newVariants`. This fix `deepClone`s the oldVariants when
sending them in as an `applyPatch` parameter so that the `oldVariants`
variable is left untouched.


![image](https://github.com/Unleash/unleash/assets/14320932/089e118d-c5c4-432e-b11c-08d362ce155d)
This commit is contained in:
Nuno Góis 2023-09-14 12:22:20 +01:00 committed by GitHub
parent 93ccb06f6d
commit f68b0ad001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1898,7 +1898,10 @@ class FeatureToggleService {
featureName, featureName,
environment, environment,
); );
const { newDocument } = await applyPatch(oldVariants, newVariants); const { newDocument } = await applyPatch(
deepClone(oldVariants),
newVariants,
);
return this.crProtectedSaveVariantsOnEnv( return this.crProtectedSaveVariantsOnEnv(
project, project,
featureName, featureName,