Skip to content

fix: Make TestData ValueForAll return its value when targeting is off - #400

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. The method already replaced variations with a single value and set fallthrough via VariationForAll(0), but it left the default boolean off variation index at 1, which is out of range for a one-variation flag and produced a malformed flag instead of the documented “same value on or off” behavior.

ValueForAll now also calls OffVariation(0) after VariationForAll(0); VariationForAll behavior is unchanged. New unit tests assert the built flag shape (targeting on/off) and an integration test confirms LdClient returns the configured string when targeting is off.

Reviewed by Cursor Bugbot for commit 9de4a3d. 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 c8fef92 into main Nov 6, 2026
21 of 23 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3477/value-for-all branch November 6, 2026 17:06
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