Describe the bug
When starting an app with the launchdarkly-server-sdk I get the following error:
I, [2024-03-20T13:20:56.879571 #2115] INFO -- : [LDClient] Initializing stream connection
I, [2024-03-20T13:20:56.883992 #2115] INFO -- : Connecting to event stream at https://stream.launchdarkly.com/all
E, [2024-03-20T13:20:57.472795 #2115] ERROR -- : [LDClient] Data inconsistency in feature flag "feature_flag_B": prerequisite has invalid variation index
I, [2024-03-20T13:20:57.479488 #2115] INFO -- : [LDClient] Stream initialized
feature_flag_B has a prerequisite feature_flag_A on variation 2 (live)
feature_flag_A has 4 variations [off , onboarding, live, offboarding]
To reproduce
Create feature_flag_A with 4 variations
Create feature_flag_B with two variations
Make feature_flag_A with variation of index 2 a prerequisite of feature_flag_B
When starting the app with those feature flags the error will appear as ERROR -- : [LDClient] Data inconsistency in feature flag "feature_flag_B": prerequisite has invalid variation index.
Expected behavior
When starting the app no error is logged.
Describe the bug When starting an app with the launchdarkly-server-sdk I get the following error:
feature_flag_B
has a prerequisitefeature_flag_A
on variation 2 (live
)feature_flag_A
has 4 variations [off
,onboarding
,live
,offboarding
]To reproduce
feature_flag_A
with 4 variationsfeature_flag_B
with two variationsfeature_flag_A
with variation of index 2 a prerequisite offeature_flag_B
ERROR -- : [LDClient] Data inconsistency in feature flag "feature_flag_B": prerequisite has invalid variation index
.Expected behavior When starting the app no error is logged.
SDK version 7.2.0
Language version, developer tools ruby 3.2.2
OS/platform Ubuntu 22.04
Additional context I believe the code path followed to get the error is: When creating the
feature_flag_B
at https://github.com/launchdarkly/ruby-server-sdk/blob/389953b477a241cbfd0694a5516a1e39ebf9c7ee/lib/ldclient-rb/impl/model/feature_flag.rb#L40 There will be a prerequisite{:key=>"feature_flag_A", :variation=>2}
, which will create a Prerequisite https://github.com/launchdarkly/ruby-server-sdk/blob/389953b477a241cbfd0694a5516a1e39ebf9c7ee/lib/ldclient-rb/impl/model/feature_flag.rb#L120-L128 and callcheck_variation_range
https://github.com/launchdarkly/ruby-server-sdk/blob/389953b477a241cbfd0694a5516a1e39ebf9c7ee/lib/ldclient-rb/impl/model/feature_flag.rb#L7-L13 Which compares thefeature_flag_B.variations.length
withfeature_flag_A
prerequisite variation2
. I believe the intended action would be to compare thefeature_flag_A.variations.length
instead.