File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
lib/devcycle-ruby-server-sdk/api Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -49,14 +49,18 @@ def self.user_from_openfeature_context(context)
4949 end
5050 args = { }
5151 user_id = nil
52+ user_id_field = nil
5253
5354 # Priority order: targeting_key -> user_id -> userId
5455 if context . field ( 'targeting_key' )
5556 user_id = context . field ( 'targeting_key' )
57+ user_id_field = 'targeting_key'
5658 elsif context . field ( 'user_id' )
5759 user_id = context . field ( 'user_id' )
60+ user_id_field = 'user_id'
5861 elsif context . field ( 'userId' )
5962 user_id = context . field ( 'userId' )
63+ user_id_field = 'userId'
6064 end
6165
6266 # Validate user_id is present and is a string
@@ -65,7 +69,7 @@ def self.user_from_openfeature_context(context)
6569 end
6670
6771 unless user_id . is_a? ( String )
68- raise ArgumentError , "User ID must be a string, got #{ user_id . class } "
72+ raise ArgumentError , "User ID field ' #{ user_id_field } ' must be a string, got #{ user_id . class } "
6973 end
7074
7175 # Check after type validation to avoid NoMethodError on non-strings
Original file line number Diff line number Diff line change 1616 context = OpenFeature ::SDK ::EvaluationContext . new ( targeting_key : 123 )
1717 expect {
1818 DevCycle ::Provider . user_from_openfeature_context ( context )
19- } . to raise_error ( ArgumentError , "User ID must be a string, got Integer" )
19+ } . to raise_error ( ArgumentError , "User ID field 'targeting_key' must be a string, got Integer" )
2020 end
2121
2222 it 'raises error when user_id is not a string' do
2323 context = OpenFeature ::SDK ::EvaluationContext . new ( user_id : 123 )
2424 expect {
2525 DevCycle ::Provider . user_from_openfeature_context ( context )
26- } . to raise_error ( ArgumentError , "User ID must be a string, got Integer" )
26+ } . to raise_error ( ArgumentError , "User ID field 'user_id' must be a string, got Integer" )
2727 end
2828
2929 it 'raises error when userId is not a string' do
3030 context = OpenFeature ::SDK ::EvaluationContext . new ( userId : 123 )
3131 expect {
3232 DevCycle ::Provider . user_from_openfeature_context ( context )
33- } . to raise_error ( ArgumentError , "User ID must be a string, got Integer" )
33+ } . to raise_error ( ArgumentError , "User ID field 'userId' must be a string, got Integer" )
3434 end
3535
3636 it 'raises error when targeting_key is nil' do
You can’t perform that action at this time.
0 commit comments