Repository navigation
feat: Add flag override tests for a client whose store holds flags without the init key - #539
Merged
Merged
Conversation
…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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 overridesgroup in the persistent data store suite (server_side_persistence_overrides.go) runs when the test service has theflag-overridescapability. 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: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-testsagainst Redis.v7main57498a9e)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 at30d4f216(131 tests run).golangci-lintreports 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
$initedkey—a case the existing in-memory override suite could not distinguish from “read everything from the store.”A new
flag overridesgroup under the server-side persistent data store suite (server_side_persistence_overrides.go, gated onflag-overrides) seeds Redis/Consul/Dynamo with flags, uses a blocking unavailable data source, and compares clients with and without override files viauninitializedClient. 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 clientgroup 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 fromserver_side_persistence_base.go.Reviewed by Cursor Bugbot for commit 09a8e02. Bugbot is set up for automated code reviews on this repo. Configure here.