-
Notifications
You must be signed in to change notification settings - Fork 55
Description
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_Awith 4 variations - Create
feature_flag_Bwith two variations - Make
feature_flag_Awith variation of index 2 a prerequisite offeature_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.
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
| Prerequisite.new(prereq_data, self, errors) |
There will be a prerequisite
{:key=>"feature_flag_A", :variation=>2}, which will create a Prerequisiteruby-server-sdk/lib/ldclient-rb/impl/model/feature_flag.rb
Lines 120 to 128 in 389953b
| class Prerequisite | |
| def initialize(data, flag, errors_out = nil) | |
| @data = data | |
| @key = data[:key] | |
| @variation = data[:variation] | |
| @failure_result = EvaluatorHelpers.evaluation_detail_for_off_variation(flag, | |
| EvaluationReason::prerequisite_failed(@key)) | |
| check_variation_range(flag, errors_out, @variation, "prerequisite") | |
| end |
and call
check_variation_rangeruby-server-sdk/lib/ldclient-rb/impl/model/feature_flag.rb
Lines 7 to 13 in 389953b
| def check_variation_range(flag, errors_out, variation, description) | |
| unless flag.nil? || errors_out.nil? || variation.nil? | |
| if variation < 0 || variation >= flag.variations.length | |
| errors_out << "#{description} has invalid variation index" | |
| end | |
| end | |
| end |
Which compares the
feature_flag_B.variations.length with feature_flag_A prerequisite variation 2. I believe the intended action would be to compare the feature_flag_A.variations.length instead.Metadata
Metadata
Assignees
Labels
No labels