Skip to content

Commit 21f2f43

Browse files
authored
Merge pull request #604 from splitio/FME-12475-fix-rbs-matcher
[Fix] RBS implementation not up to spec
2 parents b21a8b6 + f90f6be commit 21f2f43

File tree

6 files changed

+92
-10
lines changed

6 files changed

+92
-10
lines changed

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
CHANGES
22

3+
8.10.1 (Jan 21, 2025)
4+
- Fixed rule-based segment matcher.
5+
36
8.10.0 (Nov 28, 2025)
4-
- Replaced socketry gem used in streaming feature with built-in socket lib.
7+
- Updated socketry gem used in streaming feature with built-in socket lib.
58

69
8.9.0 (Oct 8, 2025)
710
- Added new configuration for Fallback Treatments, which allows setting a treatment value and optional config to be returned in place of "control", either globally or by flag. Read more in our docs.

lib/splitclient-rb/engine/matchers/rule_based_segment_matcher.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ def match?(args)
3030

3131
return false unless check_excluded_segments(rule_based_segment, key, args)
3232

33-
matches = false
33+
matched = false
3434
rule_based_segment[:conditions].each do |c|
3535
condition = SplitIoClient::Condition.new(c, @config)
3636
next if condition.empty?
3737

38-
matches = Helpers::EvaluatorHelper.matcher_type(condition, @segments_repository, @rule_based_segments_repository).match?(args)
38+
matched = Helpers::EvaluatorHelper.matcher_type(condition, @segments_repository, @rule_based_segments_repository).match?(args)
39+
40+
break if matched
3941
end
40-
@logger.debug("[InRuleSegmentMatcher] #{@segment_name} is in rule based segment -> #{matches}")
41-
matches
42+
43+
@logger.debug("[InRuleSegmentMatcher] #{@segment_name} is in rule based segment -> #{matched}")
44+
matched
4245
end
4346

4447
private

lib/splitclient-rb/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SplitIoClient
2-
VERSION = '8.10.1-rc1'
2+
VERSION = '8.10.1-rc.2'
33
end

spec/engine/matchers/rule_based_segment_matcher_spec.rb

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,61 @@
177177
matcher = described_class.new(segments_repository, rbs_repositoy, 'sample_rule_based_segment', config)
178178
expect(matcher.match?(value: 'bilal@split.io', attributes: {'email': 'bilal@split.io'})).to be true
179179
expect(matcher.match?(value: 'bilal', attributes: {'email': 'bilal'})).to be false
180-
end
180+
end
181+
182+
it 'return true if has multiple conditions' do
183+
rbs_repositoy = SplitIoClient::Cache::Repositories::RuleBasedSegmentsRepository.new(config)
184+
rbs = {
185+
:name => 'sample_rule_based_segment',
186+
:trafficTypeName => 'tt_name_1',
187+
:conditions => [
188+
{
189+
:matcherGroup => {
190+
:combiner => "AND",
191+
:matchers => [
192+
{
193+
:matcherType => "WHITELIST",
194+
:negate => false,
195+
:userDefinedSegmentMatcherData => nil,
196+
:whitelistMatcherData => {
197+
:whitelist => [
198+
"bilal"
199+
]
200+
},
201+
:unaryNumericMatcherData => nil,
202+
:betweenMatcherData => nil
203+
}
204+
]
205+
}
206+
},
207+
{
208+
:matcherGroup => {
209+
:combiner => "AND",
210+
:matchers => [
211+
{
212+
:matcherType => "WHITELIST",
213+
:negate => false,
214+
:userDefinedSegmentMatcherData => nil,
215+
:whitelistMatcherData => {
216+
:whitelist => [
217+
"mauro"
218+
]
219+
},
220+
:unaryNumericMatcherData => nil,
221+
:betweenMatcherData => nil
222+
}
223+
]
224+
}
225+
}
226+
],
227+
:excluded => {:keys => [], :segments => []}
228+
}
229+
230+
rbs_repositoy.update([rbs], [], -1)
231+
matcher = described_class.new(segments_repository, rbs_repositoy, 'sample_rule_based_segment', config)
232+
expect(matcher.match?(value: 'mauro', attributes: {})).to be true
233+
expect(matcher.match?(value: 'bilal', attributes: {})).to be true
234+
expect(matcher.match?(value: 'nicolas', attributes: {})).to be false
235+
end
181236
end
182237
end

spec/integrations/in_memory_client_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,8 +1401,8 @@
14011401
client_rbs = factory_rbs.client
14021402
client_rbs.block_until_ready
14031403

1404-
expect(client_rbs.get_treatment('bilal@split.io', 'rbs_feature_flag', {:email => 'bilal@split.io'})).to eq('on')
1405-
expect(client_rbs.get_treatment('mauro@split.io', 'rbs_feature_flag', {:email => 'mauro@split.io'})).to eq('off')
1404+
expect(client_rbs.get_treatment('bilal', 'rbs_feature_flag', {:email => 'bilal@split.io'})).to eq('on')
1405+
expect(client_rbs.get_treatment('mauro', 'rbs_feature_flag', {:email => 'mauro@split.io'})).to eq('off')
14061406
end
14071407
end
14081408

spec/test_data/rule_based_segments/rule_base_segments.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"name": "dependent_rbs",
7979
"status": "ACTIVE",
8080
"trafficTypeName": "user",
81-
"excluded":{"keys":["mauro@split.io","gaston@split.io"],"segments":[]},
81+
"excluded":{"keys":["mauro","gaston@split.io"],"segments":[]},
8282
"conditions": [
8383
{
8484
"conditionType": "WHITELIST",
@@ -100,6 +100,27 @@
100100
}
101101
]
102102
}
103+
},
104+
{
105+
"conditionType": "WHITELIST",
106+
"matcherGroup": {
107+
"combiner": "AND",
108+
"matchers": [
109+
{
110+
"keySelector": {
111+
"trafficType": "user",
112+
"attribute": "email"
113+
},
114+
"matcherType": "ENDS_WITH",
115+
"negate": false,
116+
"whitelistMatcherData": {
117+
"whitelist": [
118+
"@harness.io"
119+
]
120+
}
121+
}
122+
]
123+
}
103124
}
104125
]},
105126
{

0 commit comments

Comments
 (0)