Skip to content

fix: Prevent flags in a persistent store from becoming available to mobile keys - #275

Merged
keelerm84 merged 1 commit into
mainfrom
mk/SDK-3622/client-side-availability
Nov 19, 2026
Merged

keelerm84 merged 1 commit into
mainfrom
mk/SDK-3622/client-side-availability

Conversation

@keelerm84

@keelerm84 keelerm84 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

FeatureFlag did not model clientSideAvailability, so the SDK dropped the object when it wrote a flag to Redis, Consul or DynamoDB. A reader of the store that uses the object, such as the Go SDK or the Relay Proxy, then treats the flag with the older rule and makes it available to mobile keys, even when the flag says usingMobileKey: false.

FeatureFlag now keeps the object when the flag JSON has it, and the SDK writes it back with both properties. A property missing from the object reads as false. When the object is present, clientSide takes the value of usingEnvironmentId, as in the Go SDK. A flag without the object keeps its current encoding and behavior.

The clientSide value is set when the flag is read, so serialization still uses the existing adapter with no extra cost.

The new persistent data store/<store>/client-side availability tests in the test harness (launchdarkly/sdk-test-harness#657 for v3, launchdarkly/sdk-test-harness#658 for v2) pass with this change on Redis, Consul and DynamoDB, and fail without it.

Opened from termag


Note

Overview
Fixes loss of clientSideAvailability when the Java server SDK serializes feature flags to persistent data stores, which could make flags incorrectly available to mobile clients.

FeatureFlag now models optional ClientSideAvailability (usingMobileKey, usingEnvironmentId). On deserialize, if that object is present, clientSide is derived from usingEnvironmentId (matching Go SDK behavior) and both fields are written back on serialize. Missing object properties default to false; flags without the object keep legacy clientSide-only JSON.

ModelBuilders gains clientSideAvailability(...); tests cover round-trip serialization and constructor updates.

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

…istent store

FeatureFlag did not model clientSideAvailability, so the SDK dropped the
object when it wrote a flag to Redis, Consul or DynamoDB. A Go SDK or the
Relay Proxy then read usingMobileKey as true for that flag.

FeatureFlag now keeps the object if the JSON has it. When the object is
present, clientSide takes the value of usingEnvironmentId, as in the Go
SDK, and the SDK writes the object with both properties. A flag without
the object keeps its current encoding and behavior.

Generated-by: termag
@keelerm84
keelerm84 requested a review from a team as a code owner November 19, 2026 21:08
@cursor cursor Bot added the risk:medium label Nov 19, 2026

@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.

Automated risk review (dry run): Medium

This PR would not be automatically approved. Human approval required.

Why: The change in DataModel.java preserves clientSideAvailability on flags written to persistent stores, which is an authorization-related control over mobile-key availability, so this cannot be Low despite the added serialization tests. Human review is needed and no reviewers were assigned.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@keelerm84
keelerm84 merged commit 32c8676 into main Nov 19, 2026
35 of 39 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3622/client-side-availability branch November 19, 2026 21:21
kinyoklion pushed a commit that referenced this pull request Nov 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.18.2](launchdarkly-java-server-sdk-7.18.1...launchdarkly-java-server-sdk-7.18.2)
(2026-11-20)


### Bug Fixes

* Clear empty FDv2 selectors in shared protocol handling
([#261](#261))
([576b081](576b081))
* Prevent flags in a persistent store from becoming available to mobile
keys ([#275](#275))
([32c8676](32c8676))
* Treat a null optional property in flag data as omitted
([#268](#268))
([3af465d](3af465d))
* Update launchdarkly-java-sdk-internal to 1.13.0
([#272](#272))
([9cc5885](9cc5885))

---
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**
> This **release PR** bumps the LaunchDarkly Java server SDK from
**7.18.1** to **7.18.2** across Release Please metadata
(`gradle.properties`, `Version.SDK_VERSION`, and
`.release-please-manifest.json`).
> 
> The new **CHANGELOG** section records the fixes shipped in this patch:
clearing empty FDv2 selectors in shared protocol handling, blocking
persistent-store flags from being exposed to mobile keys, treating null
optional flag properties as omitted, and updating
`launchdarkly-java-sdk-internal` to 1.13.0. Those behavioral changes are
not part of this diff—only the version and release notes are updated
here.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
9087581. 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 that referenced this pull request Dec 3, 2026
… evaluations (#221)

<!-- TERMAG_PR_BODY_BEGIN -->
## Update, 2026-12-03

- `launchdarkly-java-sdk-common` 2.6.0 is released from `main` (#298).
Its source is the same as on `feat/overrides`, and the pin is unchanged.
- Verified against the Maven Central artifact: this head builds, with
the contract test service, and CI passes.

## Update, 2026-12-01

- Rebased onto `feat/overrides`, which has `main` merged into it again.
From `main` it gets the 7.19.0 to 7.19.2 releases, `java-sdk-internal`
1.14.0, and the FDv2 fix that leaves out an empty selector (#261). The
v3.2.0-alpha.21 contract tests check that fix, so CI failed three FDv2
streaming tests without it.
- Rebase conflict in `build.gradle`: `main`'s internal 1.14.0, with this
PR's common 2.6.0.
- `main` added a `clientSideAvailability` argument to the `FeatureFlag`
constructor (#275). The marked copy of a flag now passes it on, so an
override keeps the flag's client-side availability. The change is in the
first commit, and its test checks it.
- Verified with the v3.2.0-alpha.21 harness that CI runs, with `common`
2.6.0 and `internal` 1.15.0 published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
- the server unit tests pass at the top (2348, with the 72 existing
skips);
- the full v3 contract tests pass at the top (6457 tests ran). That
includes the flag overrides suite and both flag listener suites.

## Update, 2026-11-13

- Rebased onto `feat/overrides`, which now includes #218 and #219 and
has `main` merged into it. From `main` it gets the 7.18.0 release, CI on
the latest v3 contract tests, flag change listener support in the
contract test service, and the `java-sdk-internal` 1.12.1 and 1.12.2
fixes. A common 2.6.0 and internal 1.13.0 release from this branch needs
those fixes.
- Rebase conflicts with `main`, both resolved by keeping both sides:
- `Evaluator.java`: `main`'s #258 keeps the big segments status on an
error reason, and this PR marks that result as override-affected.
- `build.gradle`: `main`'s `jsr305` and internal 1.12.2, with this PR's
common 2.6.0.
- Verified at the top of the stack, with `common` and `internal`
published locally from `feat/overrides`:
  - every PR in the stack compiles, with Javadoc, at its own head;
  - the server unit tests pass (2285, with the 72 existing skips);
- the full v3 contract tests pass (6321 tests). That includes the flag
overrides suite, with the deleted-entry tests of
launchdarkly/sdk-test-harness#599, and both flag listener suites.

## Summary

The OVERRIDE specification requires an evaluation to be marked as
override-affected when any definition it read carried the override
marker: the evaluated flag, a prerequisite at any depth, or a segment
consulted during matching, whether or not the segment matched. The
marking propagates upward only: a prerequisite's own record reflects
only the definitions that its own subtree read, while the evaluation
that requested it accumulates the result. An evaluation that fails is
still marked when it read a marked definition, and a requested-type
mismatch keeps the marking on its error reason, as does the WRONG_TYPE
error that `migrationVariation` returns for an unrecognized stage.

- `DataModel.FeatureFlag` and `DataModel.Segment` carry a transient
`isOverride` marker. It is never serialized and never read from JSON.
`markedAsOverride()` returns a shallow copy with the marker set, sharing
nested collections and preprocessing with the source and never modifying
it. The override layer will use it in the next change.
- The evaluator tracks the marking per evaluation scope. The scope
starts from its own flag's marker, each segment read can set it, and the
value is saved, reset to the prerequisite's own marker, and restored
around every prerequisite evaluation. Each result and each prerequisite
record carries the marking on its reason.
- `EvalResult.isOverrideAffected()` reads the reason's indicator, and
`withOverrideAffected(boolean)` returns a copy so that the shared
precomputed results are never mutated.
- An evaluation that throws returns an `EXCEPTION` result marked with
the evaluated flag's own marker, because that definition was read before
the failure.
- The server SDK now depends on launchdarkly-java-sdk-common 2.6.0,
which adds `EvaluationReason.isOverrideAffected()` and the
`overrideAffected` JSON property (written only when true).

Flag overrides are currently experimental and subject to change.

The existing file data source keeps its current behavior; this change
does not touch its code paths.

[SDK-3246](https://launchdarkly.atlassian.net/browse/SDK-3246)


[SDK-3246]:
https://launchdarkly.atlassian.net/browse/SDK-3246?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Overview**
> Adds **experimental flag-override tracking** so evaluations can report
when they were influenced by local override definitions rather than
LaunchDarkly data.
> 
> **FeatureFlag** and **Segment** gain a transient `isOverride` marker
(never serialized) and `markedAsOverride()` shallow copies for the
override layer to use. The **Evaluator** tracks whether the current
scope read any marked flag, prerequisite subtree, or segment (match or
not), propagating upward while keeping each prerequisite record scoped
to its own subtree. **`EvalResult`** exposes `isOverrideAffected()` and
`withOverrideAffected()` via `EvaluationReason` so shared precomputed
results stay immutable.
> 
> **InputValidatingEvaluator**, **MigrationStageEnforcingEvaluator**,
and `allFlagsState` preserve override marking across type errors,
exceptions, and malformed evaluations. Dependency
**`launchdarkly-java-sdk-common`** is bumped to **2.6.0** for
`EvaluationReason.isOverrideAffected()`.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
a2a5c8e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
<!-- TERMAG_PR_BODY_END -->

<!-- termag: box=i-0575d1c54853058d7 project=java-core -->
<sub>Opened from termag</sub>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants