Skip to content

feat: Add flag override tests for a client whose store holds flags without the init key - #539

Merged
kinyoklion merged 1 commit into
v3from
rlamb/override-all-flags-uninitialized-store
Nov 3, 2026
Merged

kinyoklion merged 1 commit into
v3from
rlamb/override-all-flags-uninitialized-store

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Overrides only add to what the SDK reports: a flag that the override layer does not hold evaluates as it does without an override source, and the all-flags state holds every flag it holds without one, plus the overridden flags. A client that has not initialized is where SDKs broke this, and only when the store holds flags without being initialized, for example a persistent store that holds data but no init key. The flag overrides suite uses the SDK's in-memory store, which is empty until a data source provides data, so it could not tell a read of the override layer apart from a read of everything the store returns.

A new flag overrides group in the persistent data store suite (server_side_persistence_overrides.go) runs when the test service has the flag-overrides capability. It writes flags to the store without the init key and gives the client a data source that never provides data. Each test compares a client with an override source to a client without one against the same store, so it holds whatever an SDK reports for an uninitialized store:

  • a flag without an override evaluates as it does without an override source: an override file that holds a different flag leaves the evaluation of a store flag unchanged (OVERRIDE Requirements 1.5.1 and 1.5.3).
  • an empty override source leaves the all-flags state unchanged (Requirement 1.2.2).
  • overrides add to the all-flags state and make it valid: the state holds exactly the flags of the client without a source, with override values for the overridden keys, plus the flags that exist only in the override layer, and it is valid (launchdarkly/sdk-specs#280, Requirements 1.4.1.2 and 1.4.1.3).

The flag overrides suite gains evaluate all flags returns only the override flags as a valid state in its uninitialized client group, where the store is empty and every SDK reports only the override flags.

Results

Run with -enable-persistence-tests against Redis.

Test service flag without an override empty override source overrides add
Go v7 fails: served from the store fails: valid state of the store's flags fails: the store's flags join the overrides
Go launchdarkly/go-server-sdk#491 passes passes passes
Node main passes fails: valid state of the store's flags passes
Node launchdarkly/js-core#2132 first commit (57498a9e) passes passes fails: drops a store flag the state holds without overrides
Node launchdarkly/js-core#2132 passes passes passes
Python (top of the launchdarkly/python-server-sdk#530 stack, sync and async) passes passes passes
Ruby (top of the launchdarkly/ruby-server-sdk#454 stack) passes passes passes

The Java (launchdarkly/java-core#225) and .NET (dotnet-server-sdk-v9) test services do not support persistent stores, so the group skips there; the new uninitialized client test passes on both. The full Redis persistent data store suite and the flag overrides suite pass against Go #491 at 30d4f216 (131 tests run). golangci-lint reports no issues.

Go and Node fail these tests until launchdarkly/go-server-sdk#491 and launchdarkly/js-core#2132 are merged, for test services whose CI runs the persistent data store suite with this harness version.

SDK-3419

Opened from termag


Note

Overview
Adds harness coverage for file flag overrides when the SDK never initializes but a persistent store already holds feature data without the $inited key—a case the existing in-memory override suite could not distinguish from “read everything from the store.”

A new flag overrides group under the server-side persistent data store suite (server_side_persistence_overrides.go, gated on flag-overrides) seeds Redis/Consul/Dynamo with flags, uses a blocking unavailable data source, and compares clients with and without override files via uninitializedClient. Scenarios assert: store flags not in the override file behave like no override source; an empty override file leaves evaluate all flags unchanged; overrides merge into all-flags state, mark it valid, and apply override values while retaining other store flags.

The standalone flag-overrides uninitialized client group gains evaluate all flags returns only the override flags as a valid state (empty store, overrides-only valid state). The persistent suite registers the new group from server_side_persistence_base.go.

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

…thout the init key

A store that is not initialized can still hold flags, which the in-memory store used by the flag overrides suite never does. The persistent data store suite now checks, for a client that has not initialized, that a flag without an override evaluates as it does without an override source, that an empty override source leaves the all-flags state unchanged, and that overrides only add to the all-flags state and make it valid. The flag overrides suite checks that the all-flags state of an uninitialized client holds only the override flags and is valid.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Approved. Bugbot completed with no findings that need human review, and this change is limited to test-harness coverage for flag overrides on an uninitialized persistent store.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@kinyoklion
kinyoklion merged commit 3c1ba64 into v3 Nov 3, 2026
10 checks passed
@kinyoklion
kinyoklion deleted the rlamb/override-all-flags-uninitialized-store branch November 3, 2026 16:50
kinyoklion pushed a commit that referenced this pull request Nov 3, 2026
🤖 I have created a release *beep* *boop*
---


##
[3.2.0-alpha.16](v3.2.0-alpha.15...v3.2.0-alpha.16)
(2026-11-03)


### Features

* Add evaluation tests for a segment referenced more than once
([#553](#553))
([96e64a8](96e64a8))
* Add evaluation tests for clause values of the wrong type
([#550](#550))
([e5abd40](e5abd40))
* Add evaluation tests for falsy and look-alike variation values
([#554](#554))
([57692bd](57692bd))
* Add evaluation tests for numbers in exponent notation
([#551](#551))
([e5788fe](e5788fe))
* Add evaluation tests for old user built-in attributes
([#555](#555))
([411a4df](411a4df))
* Add evaluation tests for rollout bucket boundaries and seeded rollouts
([#552](#552))
([c17486a](c17486a))
* Add flag override tests for a client whose store holds flags without
the init key
([#539](#539))
([3c1ba64](3c1ba64))


### Bug Fixes

* Make evaluation data files test what they claim
([#556](#556))
([e3b844d](e3b844d))

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

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> **Release 3.2.0-alpha.16** bumps the harness version in `main.go`,
`.release-please-manifest.json`, and documents the release in
`CHANGELOG.md`.
> 
> This alpha release **expands SDK contract coverage** rather than
changing harness runtime behavior in the diff itself. New **evaluation**
scenarios cover segments referenced multiple times, clause values with
wrong types, falsy or look-alike variation values, exponent-notation
numbers, legacy user built-in attributes, and rollout bucket boundaries
with seeded rollouts. **Flag override** tests now include a client whose
persistent store holds flags **without the init key**.
> 
> A **bug fix** aligns evaluation data files with the behaviors they are
meant to exercise
([#556](#556)),
which may surface new failures in SDKs that were passing mismatched
fixtures.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
046db1b. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kinyoklion added a commit to launchdarkly/go-server-sdk that referenced this pull request Nov 4, 2026
…valuations and AllFlagsState, and report a store failure (#491)

<!-- TERMAG_PR_BODY_BEGIN -->
## Summary

Overrides only add to what the SDK reports: a flag that the override
layer does not hold must evaluate, and appear in `AllFlagsState`, as it
does without an override source. Three paths broke this. The first two
were found while reviewing the same code in the .NET port (dotnet-core
#364), the third by the contract tests in
launchdarkly/sdk-test-harness#539.

1. **`AllFlagsState` with no LaunchDarkly data and an override source
configured.** The state was built from the merged read through the
overlay, so the flags of a store that is not initialized (a persistent
store that holds flags but no init marker) entered it. With an empty
layer, that returned a valid state of LaunchDarkly data that the SDK
returns as invalid without an override source; with overrides present,
the state held those flags alongside the overrides. Without an override
source the SDK reports no flags in this state.
2. **`AllFlagsState` when the store read fails.** `Overlay.GetAll`
returned the layer's entries alone, with no error, when the base store
failed and the layer held entries. An initialized client (daemon mode,
for example) whose store fails `GetAll` then returned a state marked
valid with only the override flags and logged nothing. Without an
override source, the same failure logs it and returns an invalid, empty
state.
3. **Evaluation with no LaunchDarkly data and an override source
configured.** Every key was read through the overlay, so a flag that the
layer does not hold fell through to the store, and a store that holds
flags but no init marker served them. Without an override source the
same evaluation returns the not-ready default.

The fixes:

- The overrides-only state is built from the layer's flags directly,
read through a new `FDv2.OverrideItems`, and only when no LaunchDarkly
data is available; a layer without flags still gives an invalid state.
Without an override source the SDK reports no flags in this state, so
the override flags only add to it.
- `Overlay.GetAll` returns the base error whatever the layer holds.
`AllFlagsState` is its only caller; per-key `Get` still serves an
override entry without the base. When the store's read fails,
`AllFlagsState` logs the failure as before and returns an invalid state
that holds the override layer's flags, and with none it is empty as
without a source. `flagstate.AllFlagsBuilder` gains `Valid(bool)` so
that a state can be invalid and still hold flags. A client-side SDK
bootstrapped from the state uses its flags whatever `$valid` says
(js-client-sdk 3.x and the 4.x browser SDK only log a warning), so the
overridden values still reach it.
- With no LaunchDarkly data, evaluation reads the flag from the layer
itself through a new `FDv2.OverrideItem`, and a miss returns the
not-ready default. Prerequisites and segments are still read through the
overlay.

These follow OVERRIDE Requirements 1.2.2 and 1.5.3, and Requirements
1.4.1.2 and 1.4.1.3 proposed in launchdarkly/sdk-specs#280, which
replace the sentence in Requirement 1.4.1 that the uninitialized state
contains only the overridden flags.

## Tests

- `ldclient_overrides_test.go`, with a persistent store that holds a
flag but no init marker and a client that never initializes:
- an empty override layer gives an invalid, empty state, and a layer
with one flag gives a valid state with only that flag;
- an empty override layer gives the not-ready default for the store's
flag, and a layer that holds another flag gives the not-ready default
for the store's flag while serving the overridden one.
- `ldclient_overrides_test.go`, in daemon mode: with an override
present, a store read failure gives an invalid state that holds the
overridden flag with its marked reason and tracking off, and logs the
failure; with no override flags the same failure gives an invalid, empty
state.
- `interfaces/flagstate/flags_state_test.go`: a builder marked invalid
keeps its flags and serializes `"$valid": false` with them.
- `internal/overrides/overrides_test.go`: the overlay test that pinned
the old behavior now asserts that `GetAll` returns the base error with
entries in the layer, while `Get` still serves the override entry.

Each fix fails its tests when reverted. `go test -race ./...` passes and
`make lint` reports no issues. The contract tests in
launchdarkly/sdk-test-harness#539 fail on `v7` and pass on this branch,
together with the full Redis persistent data store and flag overrides
suites (131 tests).

[SDK-3419](https://launchdarkly.atlassian.net/browse/SDK-3419)
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=go-server-sdk -->
<sub>Opened from termag</sub>


[SDK-3419]:
https://launchdarkly.atlassian.net/browse/SDK-3419?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
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.

1 participant