launchdarkly / ruby-server-sdk

LaunchDarkly Server-side SDK for Ruby
https://docs.launchdarkly.com/sdk/server-side/ruby
Other
34 stars 50 forks source link

Error with `FileData` and `add_flag_value_change_listener` #281

Closed jscheid closed 2 months ago

jscheid commented 3 months ago

Is this a support request?

No

Describe the bug

An error is raised when using LaunchDarkly::Integrations::FileData (with auto_update) together with flag_tracker.add_flag_value_change_listener. The flag I'm listening on is a boolean flag (defined via flagValues in the YAML file) and I'm turning it from false to true by editing and saving the file.

To reproduce

I'm happy to boil it down to a test case if you need one.

Expected behavior

Preferably no error, or -- if I'm using the SDK in a way that isn't supported -- an informative error message.

Logs

NoMethodError: undefined method `<' for nil
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/data_source.rb:166:in `block (2 levels) in compute_changed_items_for_full_data_set'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/data_source.rb:160:in `each'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/data_source.rb:160:in `block in compute_changed_items_for_full_data_set'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/data_source.rb:156:in `each'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/data_source.rb:156:in `compute_changed_items_for_full_data_set'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/data_source.rb:68:in `init'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/integrations/file_data_source.rb:98:in `load_all'
launchdarkly-server-sdk-8.4.2/lib/ldclient-rb/impl/integrations/file_data_source.rb:170:in `block in start_listener_with_listen_gem'
listen-3.9.0/lib/listen/event/config.rb:28:in `call'
listen-3.9.0/lib/listen/event/processor.rb:117:in `block in _process_changes'
listen-3.9.0/lib/listen/thread.rb:26:in `rescue_and_log'
listen-3.9.0/lib/listen/event/processor.rb:116:in `_process_changes'
listen-3.9.0/lib/listen/event/processor.rb:25:in `block in loop_for'
<internal:kernel>:187:in `loop'
listen-3.9.0/lib/listen/event/processor.rb:20:in `loop_for'
listen-3.9.0/lib/listen/event/loop.rb:85:in `_process_changes'
listen-3.9.0/lib/listen/event/loop.rb:51:in `block in start'
listen-3.9.0/lib/listen/thread.rb:26:in `rescue_and_log'
listen-3.9.0/lib/listen/thread.rb:18:in `block in new'

SDK version

launchdarkly-server-sdk-8.4.2

Language version, developer tools

Ruby 3.3.2

OS/platform

Debian bullseye

Additional context

N/A

keelerm84 commented 3 months ago

I am sorry to hear you are experiencing this issue! I will try to look into this as soon as I am able. Due to some other time constraints, this will likely be early next week though. I will update you here once I've released a fix for you.

Tracking internally as 245560.

keelerm84 commented 3 months ago

@jscheid wanted to provide you with a quick update.

It looks like the ruby SDK is expecting a version number to always be set within that flag file. When you want to trigger a chance, you need to modify the flag definition and also increment that version number.

I believe this is a difference in behavior from other SDKs, so I'll be doing some longer, internal work to decide how we want to proceed, but I thought this might be sufficient to unblock you for now.

jscheid commented 3 months ago

Ah, good to know, thanks for the update @keelerm84.

FWIW I'd be happy if this just was documented better and the error message improved.

keelerm84 commented 2 months ago

This should be fixed in 8.5.0.