diff --git a/.gitmodules b/.gitmodules index da6957d..6b07f5f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "spec/engine-test-data"] path = spec/engine-test-data url = git@github.com:Flagsmith/engine-test-data.git - branch = main + branch = v3.5.0 diff --git a/Gemfile.lock b/Gemfile.lock index 249a91e..b1643c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -73,7 +73,7 @@ GEM ruby-progressbar (1.13.0) semantic (1.6.1) unicode-display_width (2.5.0) - uri (0.13.2) + uri (1.1.1) PLATFORMS ruby diff --git a/lib/flagsmith/engine/segments/evaluator.rb b/lib/flagsmith/engine/segments/evaluator.rb index c5d55cb..a9402f3 100644 --- a/lib/flagsmith/engine/segments/evaluator.rb +++ b/lib/flagsmith/engine/segments/evaluator.rb @@ -157,8 +157,18 @@ def traits_match_segment_condition_from_context(condition, segment_key, context) end def handle_percentage_split(condition, segment_key, context) - context_value_key = get_context_value(condition[:property], context) || get_identity_key_from_context(context) - hashed_percentage = hashed_percentage_for_object_ids([segment_key, context_value_key]) + split_key = if condition[:property].nil? || condition[:property].empty? + # No property specified - use identity key + get_identity_key_from_context(context) + else + # Property specified - must exist in context + get_context_value(condition[:property], context) + end + + # If split_key is nil, condition doesn't match + return false if split_key.nil? + + hashed_percentage = hashed_percentage_for_object_ids([segment_key, split_key]) hashed_percentage <= condition[:value].to_f end diff --git a/spec/engine-test-data b/spec/engine-test-data index 839e8d5..7840a13 160000 --- a/spec/engine-test-data +++ b/spec/engine-test-data @@ -1 +1 @@ -Subproject commit 839e8d5e5f2e9af6392062cf5e575d43c03770d4 +Subproject commit 7840a1349b601df3b6b4a089f40864f659801afb