Skip to content

fix: Make TestData valueForAll return its value when targeting is off - #251

Merged
keelerm84 merged 1 commit into
mainfrom
mk/SDK-3477/value-for-all
Nov 6, 2026
Merged

keelerm84 merged 1 commit into
mainfrom
mk/SDK-3477/value-for-all

Conversation

@keelerm84

@keelerm84 keelerm84 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

TestData.FlagBuilder.valueForAll replaced the flag's variations with the single value and then called variationForAll(0). That set the fallthrough to 0 but left the off variation unchanged. A new test flag is a boolean flag with off variation 1, so the built flag had variations: [value] and offVariation: 1. The index was out of range, and the flag failed to evaluate (malformed flag) when targeting was off. The method's documentation says it returns the value regardless of whether targeting is on or off.

valueForAll now also sets the off variation to 0. variationForAll is unchanged. The new tests check the built flag with targeting on and off, and check that a client evaluates the flag to the value when targeting is off.

This matches the Ruby fix in launchdarkly/ruby-server-sdk#489.

Opened from termag


Note

Overview
Fixes TestData.FlagBuilder.valueForAll so flags evaluate correctly when targeting is off. After collapsing variations to a single value, the builder only set fallthrough via variationForAll(0), leaving the default boolean off variation index 1—invalid for one variation and causing malformed-flag evaluation instead of returning the configured value.

valueForAll now also calls offVariation(0), matching documented behavior (same value on or off). variationForAll is unchanged. New unit and client tests cover the built flag shape and off-targeting evaluation.

Reviewed by Cursor Bugbot for commit 0a798d5. Bugbot is set up for automated code reviews on this repo. Configure here.

@keelerm84
keelerm84 marked this pull request as ready for review November 5, 2026 19:14
@keelerm84
keelerm84 requested a review from a team as a code owner November 5, 2026 19:14
@keelerm84
keelerm84 merged commit db17ab9 into main Nov 6, 2026
37 of 38 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3477/value-for-all branch November 6, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants