From f68b0ad00178829252595006ec49ececab8c1b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Thu, 14 Sep 2023 12:22:20 +0100 Subject: [PATCH] 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) --- src/lib/services/feature-toggle-service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/services/feature-toggle-service.ts b/src/lib/services/feature-toggle-service.ts index ed0c9d2108..9fdd59d049 100644 --- a/src/lib/services/feature-toggle-service.ts +++ b/src/lib/services/feature-toggle-service.ts @@ -1898,7 +1898,10 @@ class FeatureToggleService { featureName, environment, ); - const { newDocument } = await applyPatch(oldVariants, newVariants); + const { newDocument } = await applyPatch( + deepClone(oldVariants), + newVariants, + ); return this.crProtectedSaveVariantsOnEnv( project, featureName,