Skip to content

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

Merged
keelerm84 merged 1 commit into
mainfrom
mk/SDK-3477/value-for-all
Nov 10, 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

FlagBuilder::valueForAll replaced the variations with the single value and called variationForAll(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. With targeting off, the index was out of range and the flag failed to evaluate. The method is documented to return the value regardless of whether targeting is on or off.

valueForAll now also sets the off variation to 0. variationForAll is unchanged. A new test builds a flag with valueForAll, checks that offVariation is 0, turns targeting off, and checks that LDClient::variation returns the value.

Same fix as launchdarkly/ruby-server-sdk#489.

Opened from termag


Note

Overview
Fixes TestData FlagBuilder::valueForAll so flags still evaluate when targeting is turned off.

Previously the helper replaced variations with a single value and routed “on” traffic via variationForAll(0), but did not update offVariation. New TestData flags default to a boolean layout with offVariation index 1, so after valueForAll the built flag had one variation at index 0 while offVariation still pointed at index 1, causing bad evaluations when targeting was off—despite the doc saying the same value should apply on or off.

The change chains offVariation(0) after the existing setup. variationForAll is unchanged. A new integration test asserts offVariation is 0 and that LDClient::variation returns the configured value with targeting off.

Reviewed by Cursor Bugbot for commit 9fe0b55. 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 b8a9522 into main Nov 10, 2026
16 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3477/value-for-all branch November 10, 2026 12:54
keelerm84 pushed a commit that referenced this pull request Nov 10, 2026
🤖 I have created a release *beep* *boop*
---


##
[6.12.1](6.12.0...6.12.1)
(2026-11-10)


### Bug Fixes

* Include the big segments status on evaluation reasons for failed
evaluations
([#292](#292))
([2f2b1fe](2f2b1fe))
* Include the HTTP status in exceptions on evaluation reasons
([#291](#291))
([52d3303](52d3303))
* Make TestData valueForAll return its value when targeting is off
([#288](#288))
([b8a9522](b8a9522))
* Prevent allFlagsState from throwing when retrieving flags fails
([#294](#294))
([2b65bf2](2b65bf2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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