LaunchDarkly is making a minor change to the way individual flag targeting lists are stored and processed. This change will only impact a small subset of our customers, but will increase consistency and predictability of flag evaluations and enable us to deliver new features which rely on that consistency.
Previously, the configuration illustrated below would have been allowed, where the user target of test was permitted to be stored in both the true and false variations, and those variations were stored in an unordered array. The unordered array is visible in the JSON snippet below, but not in the UI screenshot.
Configurations containing this combination of duplicate targeting and unordered arrays are not common, however some customers may have created such configurations, either accidentally or intentionally.
This code snippet shows the same configuration, rendered in JSON format. Notice that the ordering of the array items and their indices do not match: variation 1 is in position 0 of the array, while variation 0 is in position 1. This is determined by the ordering of the variations by line number in the code.
When a JSON payload is evaluated in a LaunchDarkly SDK, the evaluation iterates through the variations according to the index and stops evaluating once a match is found. In this example, if the user test was passed to the configuration in question, the evaluation process would look as follows.
But, as the flag’s targeting configuration at the top of this article shows, the user test is present in both variation 0 and 1.
As part of our commitment to reliable and consistent flag targeting, LaunchDarkly will begin enforcing array ordering, so that the order of array elements is fully consistent with the indexes of those elements.
After our enforcement is complete, the same JSON payload will look like the following. Notice that now, variation 0 is in position 0 of the array, while variation 1 is in position 1.
An example evaluation process for this payload would now look as follows.
This means that with the same payload being submitted to the same targeting rule, the result would now have changed.
LaunchDarkly has identified only a small handful of customers who have built configurations that would be impacted by this enforcement. Targeting the same user in multiple variations in an unordered array is no longer supported. LaunchDarkly customers who have built these configurations can avoid any possible impact by ensuring that the same user key is not targeted by multiple variations, or if they are, that the newly enforced evaluation order produces the expected results.
We have already contacted affected customers, but if you’re one of them or would like help identifying whether your flag configurations will be impacted by this change, you can open a support ticket and we’ll be glad to help out.