From 52251b6aaee84573d7e2ed6272805b361f26829e Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Wed, 12 Nov 2025 16:36:38 +0000 Subject: [PATCH] fix: Multivariate sgement overrides not evaluated --- .gitmodules | 2 +- .../java/com/flagsmith/flagengine/Engine.java | 23 +++++++++---------- .../com/flagsmith/flagengine/enginetestdata | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.gitmodules b/.gitmodules index af072865..85b786b2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "src/test/java/com/flagsmith/flagengine/enginetestdata"] path = src/test/java/com/flagsmith/flagengine/enginetestdata url = git@github.com:Flagsmith/engine-test-data.git - tag = v3.2.1 \ No newline at end of file + tag = v3.4.1 \ No newline at end of file diff --git a/src/main/java/com/flagsmith/flagengine/Engine.java b/src/main/java/com/flagsmith/flagengine/Engine.java index 56f8c617..269c1006 100644 --- a/src/main/java/com/flagsmith/flagengine/Engine.java +++ b/src/main/java/com/flagsmith/flagengine/Engine.java @@ -124,22 +124,20 @@ private static Flags evaluateFeatures( if (contextFeatures != null) { for (FeatureContext featureContext : contextFeatures.getAdditionalProperties().values()) { + String reason; if (segmentFeatureContexts.containsKey(featureContext.getName())) { ImmutablePair segmentNameFeaturePair = segmentFeatureContexts .get(featureContext.getName()); featureContext = segmentNameFeaturePair.getRight(); - flags.setAdditionalProperty( - featureContext.getName(), - new FlagResult().withEnabled(featureContext.getEnabled()) - .withName(featureContext.getName()) - .withValue(featureContext.getValue()) - .withReason( - "TARGETING_MATCH; segment=" + segmentNameFeaturePair.getLeft()) - .withMetadata(featureContext.getMetadata())); + reason = "TARGETING_MATCH; segment=" + segmentNameFeaturePair.getLeft(); } else { - flags.setAdditionalProperty(featureContext.getName(), - getFlagResultFromFeatureContext(featureContext, identityKey)); + reason = "DEFAULT"; } + flags.setAdditionalProperty(featureContext.getName(), + getFlagResultFromFeatureContext( + featureContext, + identityKey, + reason)); } } @@ -148,7 +146,8 @@ private static Flags evaluateFeatures( private static FlagResult getFlagResultFromFeatureContext( FeatureContext featureContext, - String identityKey) { + String identityKey, + String reason) { if (identityKey != null) { List variants = featureContext.getVariants(); if (variants != null) { @@ -183,7 +182,7 @@ private static FlagResult getFlagResultFromFeatureContext( return new FlagResult().withEnabled(featureContext.getEnabled()) .withName(featureContext.getName()) .withValue(featureContext.getValue()) - .withReason("DEFAULT") + .withReason(reason) .withMetadata(featureContext.getMetadata()); } } \ No newline at end of file diff --git a/src/test/java/com/flagsmith/flagengine/enginetestdata b/src/test/java/com/flagsmith/flagengine/enginetestdata index 218757fd..839e8d5e 160000 --- a/src/test/java/com/flagsmith/flagengine/enginetestdata +++ b/src/test/java/com/flagsmith/flagengine/enginetestdata @@ -1 +1 @@ -Subproject commit 218757fd23f932760be681a09c686c9d6ef55fad +Subproject commit 839e8d5e5f2e9af6392062cf5e575d43c03770d4