feat: Add FDv2 payload application primitives#299
Draft
kinyoklion wants to merge 1 commit into
Draft
Conversation
Member
Author
|
bugbot review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 7367952. Configure here.
Two pieces the FDv2 pipeline needs to apply payloads correctly: - The flag-eval mapper uses the put-object envelope version as the evaluation result version, replacing any in-object value. The live service objects carry only flagVersion; requiring an in-object version made real payloads unparseable. - FlagManager.applyUpdates applies a set of updates without per-item version comparison, since FDv2 orders data at the payload level. A lower envelope version must still apply. An empty payload changes nothing and skips the cache write. Nothing produces FDv2 payloads for the flag manager yet.
7367952 to
8abfec4
Compare
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.
What this adds
Two pieces the FDv2 data pipeline (a later PR) needs to apply payloads to the flag store correctly. Nothing produces FDv2 payloads for the flag manager yet, so behavior is unchanged.
Envelope version is authoritative for flag-eval objects
The flag-eval mapper now parses objects with the
put-objectenvelope version substituted in, replacing any in-object value. The FDv2 wire format moved versioning onto the envelope; live service objects carry onlyflagVersion:{"key":"greekTest","kind":"flag-eval","version":420, "object":{"flagVersion":7,"value":true,"variation":0,"trackEvents":false}}The previous parse required an in-object
version, which made every real payload fail with "FDv2 payload contained invalid data." The contract test harness includes an in-object version in its mock data, which is why the suites did not catch it; verified against the live service. This matches the JS implementation, which spreads the object overversion: update.version.FlagManager.applyUpdatesApplies a set of updates from a partial payload without per-item version comparison, plumbed through
FlagPersistence/FlagUpdaterwith a single change event for the affected keys and the usual cache write-through. FDv2 orders data at the payload level, so a lower envelope version must still apply — the existingupsertdiscards it as out-of-order, which is correct for FDv1 patches but wrong here (the harness's "ignores model version" test sends exactly this). Updates remain context-checked likeupsert, and an empty update set changes nothing and skips the cache write.Known pre-existing divergence, intentionally not addressed here
Change detection (
FlagUpdater._hasChanged) compares evaluation details by value only —LDEvaluationDetail.==ignoresvariationIndexandreason— so a variation- or reason-only change applies to the store without aFlagsChangedEvent, despite the event's documentation promising reason changes. This is shared behavior acrossinit/upsert/applyUpdates(the JS SDK compares the whole descriptor) and predates this PR; fixing it here would mix a behavior change into otherwise-inert plumbing, so it is left for a separate change.Testing
Mapper tests pin the live wire shape (no in-object version parses; envelope version wins over a differing in-object value), alongside the existing put/delete/unknown-kind coverage. Flag updater tests cover applying without version comparison, a single change event for the changed keys, tombstones applied through
applyUpdates(stored and evented), and rejection of updates for an inactive context. Persistence-level tests assert a successful apply writes through to the cache, a rejected apply does not, and an empty apply skips the write.SDK-2186