Repository navigation
Conversation
Each put-object event had the project payload version. Every override raises the payload version. SDKs store the event version as the version of the flag, so after each full transfer all flags looked changed. The JS client SDK then sent change events for flags that did not change. This occurred in polling mode and after a stream reconnect. The event version is now the version of the flag. The FDv1 endpoints already use this version. The flag version goes up each time that its override changes, so SDKs still accept each update. Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
The Go server SDK reads the version from the flag JSON, not from the put-object event. The JS client SDK does not drop FDv2 updates by version. The comment now says only what client-side SDKs do. The new text also follows the Simple English rules of the repository. Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
The new test sets, sets again, removes, and sets an override on one flag. After each step, it checks that the streamed version goes up and equals the version in the next full transfer. It also checks that the other flag keeps its version. Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
nieblara
marked this pull request as ready for review
October 13, 2026 19:26
nieblara
merged commit Oct 13, 2026
3131663
into
cursor/fdv2-client-side-support-c95b
8 checks passed
nieblara
added a commit
that referenced
this pull request
Oct 13, 2026
* feat: serve the FDv2 client-side protocol from the dev server
Client-side SDKs are moving to the FDv2 endpoints, which the dev server did
not serve at all: an SDK upgraded to an FDv2-capable version and pointed at
the dev server asked for routes that were not there.
Adds POST/REPORT /sdk/poll/eval, GET /sdk/poll/eval/{context},
POST/REPORT /sdk/stream/eval and GET /sdk/stream/eval/{context}. FDv2
unifies the browser and mobile endpoints, so this one pair of routes covers
what /eval/{envId}, /meval, /sdk/evalx/{envId} and /msdk/evalx did in FDv1.
The protocol event builders are parameterized over the put-object kind and
object shape rather than forked, so the two protocols differ only in that
client-side put-objects carry a pre-evaluated flag-eval result where
server-side ones carry the flag configuration.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* test: cover the client-side FDv2 endpoints
Covers the flag-eval object shape, base64 context decoding across the
url-safe and standard variants, the credential and context matrices for
both the path and body forms, CORS preflight on all four routes, and an
end-to-end SSE stream carrying an initial transfer plus an override.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* chore: revert unrelated go.sum churn from a local go mod download
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* refactor: share the initial-response setup between FDv2 poll and stream
The two handlers loaded the project, applied overrides, and built the
initial response identically.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* fix: drop REPORT from the client-side FDv2 endpoints
The FDv2 client-side protocol takes the evaluation context in a POST body
or a GET path; REPORT is not part of it, and the JS SDK never sends it.
POST /sdk/poll/eval and POST /sdk/stream/eval now answer REPORT with 405,
and their CORS configuration no longer allows it.
The FDv1 client-side routes still accept REPORT.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* refactor: only check that the client-side FDv2 context is valid JSON
The dev server serves the same flag values to everyone, so it never uses
the evaluation context. Parsing it as a full LaunchDarkly context only
added a way to reject a request the dev server could have served.
Requests are still rejected with 400 when the context is not base64 or not
well-formed JSON. A well-formed context missing fields such as key is now
accepted.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* fix: use the flag version in FDv2 put-object events (#862)
* fix: use the flag version in FDv2 put-object events
Each put-object event had the project payload version. Every override
raises the payload version. SDKs store the event version as the version
of the flag, so after each full transfer all flags looked changed. The
JS client SDK then sent change events for flags that did not change.
This occurred in polling mode and after a stream reconnect.
The event version is now the version of the flag. The FDv1 endpoints
already use this version. The flag version goes up each time that its
override changes, so SDKs still accept each update.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* docs: correct the comment about put-object versions
The Go server SDK reads the version from the flag JSON, not from the
put-object event. The JS client SDK does not drop FDv2 updates by
version. The comment now says only what client-side SDKs do. The new
text also follows the Simple English rules of the repository.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
* test: check put-object versions with the SQLite store
The new test sets, sets again, removes, and sets an override on one
flag. After each step, it checks that the streamed version goes up and
equals the version in the next full transfer. It also checks that the
other flag keeps its version.
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
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.
Requirements
Related issues
This PR goes into the branch of #764. It fixes a problem that I found when I tested #764 in a browser.
Describe the solution you've provided
A put-object event is the FDv2 event that sends one flag to an SDK. Each put-object event has a
versionfield. The dev server put the project payload version in this field. Every override raises the payload version by 1.The JS client SDK stores this field as the version of the flag (
flagEvalUpdateToItemDescriptor). After a full transfer, the SDK compares the old flags and the new flags to find the changed flags. Every flag had a new version, so the SDK sent a change event for every flag. This occurred in polling mode and after a stream reconnect. The flag values were correct.Example: I set an override on
theme-config. The put-object version ofmax-itemschanged from 15 to 16. ItsflagVersionand its value did not change. The FDv1 endpoint/sdk/evalxkeptmax-itemsat version 1.This PR puts the version of the flag in the put-object event. The change is in
makePutObjectEvent, which the server-side and client-side paths share. The flag version is the base version plus the override version. The SQLite store raises the override version by 1 each time that you set or remove the override. As a result, the flag version goes up each time that the flag changes, and it stays the same when the flag does not change.Effect on each SDK:
applyChanges). Only its FDv1 patch and delete handlers check the version. If a later SDK version adds a version check, it will still accept each change, because the version goes up on each override action.ToStorableItems), not from the envelope. The envelope version now equals the version in the flag JSON. The SDK's FDv1 fallback uses the same rule (keyedItem.Item.Versioninfdv1_polling_data_source.go).Tests:
fdv2.go, four tests in the sdk package fail.Manual test in a browser
The test page runs
@launchdarkly/js-client-sdk4.11.2 in FDv2 mode against a local dev server. The dev server UI is on the right. The "Live flag changes received by the SDK" list shows each change event from the SDK.Before the fix, one override on
theme-config(at 06:27:02) gave a change event for all four flags:After the fix, each override gives one change event, for the flag that changed. The video shows polling mode first. Each change arrives with the next poll. Then it shows streaming mode, where the SDK shows each on and off change at once:
A
curlcheck with the fixed server shows that only the changed flag gets a new put-object version, on set and on remove:An independent review checked the other paths that change flags: project update, sync from LaunchDarkly, import, restore, and startup overrides. If a value can change without a higher flag version on these paths, the dev server sends a full transfer. A full transfer replaces the flags in the SDK, so the SDK does not drop the change.
Describe alternatives you've considered
I did not change only the client-side encoder. The server-side path uses the same function. One rule for the field is easier to understand, and the Go server SDK already uses the flag version for this field in its FDv1 fallback.
Additional context
This changes the server-side FDv2 output in one field. The
versionfield of each put-object event now has the flag version, not the payload version. Theserver-intenttarget and thepayload-transferredselector still use the payload version, so thebasishandling does not change.go test ./...passes. On this test machine,cmd/flagsTestArchivefails onmaintoo whenLD_PROJECTand the otherLD_environment variables are set. It passes when they are unset.golangci-lintis not installed on the test machine.go vetandstaticcheckpass on the sdk package.