Skip to content

Commit f354a19

Browse files
prepare 5.7.4 release (#157)
1 parent 7df35fa commit f354a19

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/ldclient-rb/user_filter.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def transform_user_props(user_props)
1515
user_private_attrs = Set.new((user_props[:privateAttributeNames] || []).map(&:to_sym))
1616

1717
filtered_user_props, removed = filter_values(user_props, user_private_attrs, ALLOWED_TOP_LEVEL_KEYS, IGNORED_TOP_LEVEL_KEYS)
18-
if user_props.has_key?(:custom)
19-
filtered_user_props[:custom], removed_custom = filter_values(user_props[:custom], user_private_attrs)
18+
custom = user_props[:custom]
19+
if !custom.nil?
20+
filtered_user_props[:custom], removed_custom = filter_values(custom, user_private_attrs)
2021
removed.merge(removed_custom)
2122
end
2223

spec/events_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ def with_processor_and_sender(config)
408408
end
409409
end
410410

411+
it "treats nil value for custom the same as an empty hash" do
412+
with_processor_and_sender(default_config) do |ep, sender|
413+
user_with_nil_custom = { key: "userkey", custom: nil }
414+
e = { kind: "identify", key: "userkey", user: user_with_nil_custom }
415+
ep.add_event(e)
416+
417+
output = flush_and_get_events(ep, sender)
418+
expect(output).to contain_exactly(e)
419+
end
420+
end
421+
411422
it "does a final flush when shutting down" do
412423
with_processor_and_sender(default_config) do |ep, sender|
413424
e = { kind: "identify", key: user[:key], user: user }

0 commit comments

Comments
 (0)