Skip to content

Commit

Permalink
fix: env variants event changelog (#4712)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
nunogois committed Sep 14, 2023
1 parent 93ccb06 commit f68b0ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/services/feature-toggle-service.ts
Expand Up @@ -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,
Expand Down

0 comments on commit f68b0ad

Please sign in to comment.