From 66d1166a6d8007aa956cdea616b6a0ec605324fe Mon Sep 17 00:00:00 2001 From: Gagan Trivedi Date: Mon, 27 Oct 2025 15:40:31 +0530 Subject: [PATCH] feat: add support for implicit identity key construction - Update engine-test-data to v3.1.0 for new test cases - Construct identity key as environment_key + "_" + identifier when not provided - Fix weight formatting in SPLIT reason to preserve decimal places (use %g instead of %.0f) --- flagengine/engine-test-data | 2 +- flagengine/engine.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/flagengine/engine-test-data b/flagengine/engine-test-data index 41c20214..6ab57ec6 160000 --- a/flagengine/engine-test-data +++ b/flagengine/engine-test-data @@ -1 +1 @@ -Subproject commit 41c202145e375c712600e318c439456de5b221d7 +Subproject commit 6ab57ec67bc84659e8b5aa41534b04fe45cc4cbe diff --git a/flagengine/engine.go b/flagengine/engine.go index e671cdbf..6258c38f 100644 --- a/flagengine/engine.go +++ b/flagengine/engine.go @@ -88,7 +88,13 @@ func getFlagResults(ec *engine_eval.EngineEvaluationContext, featureOverrides ma // Get identity key if identity exists var identityKey *string if ec.Identity != nil { - identityKey = &ec.Identity.Key + // If identity key is not provided, construct it from environment key and identifier + if ec.Identity.Key == "" { + constructedKey := ec.Environment.Key + "_" + ec.Identity.Identifier + identityKey = &constructedKey + } else { + identityKey = &ec.Identity.Key + } } if ec.Features != nil { @@ -147,7 +153,7 @@ func getFlagResultFromFeatureContext(featureName string, featureContext *engine_ cumulativeWeight += variant.Weight if hashPercentage <= cumulativeWeight { value = variant.Value - reason = fmt.Sprintf("SPLIT; weight=%.0f", variant.Weight) + reason = fmt.Sprintf("SPLIT; weight=%g", variant.Weight) break } }