fix: implement identity overrides merging logic#268
Open
xolott-ark wants to merge 1 commit intoFlagsmith:mainfrom
Open
fix: implement identity overrides merging logic#268xolott-ark wants to merge 1 commit intoFlagsmith:mainfrom
xolott-ark wants to merge 1 commit intoFlagsmith:mainfrom
Conversation
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.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #267
When an environment document contained multiple identity override entries for the same
identifier, the SDK only kept the last one because it builtidentitiesWithOverridesByIdentifierwithnew Map(...entries). Later entries overwrote earlier ones, so feature overrides set on previous entries silently disappeared during local evaluation.This PR replaces that map construction with a
parseIdentityOverrideshelper that:environment.identityOverridesand groups entries byidentifier.IdentityModel(preserving its prototype) and wrapsidentityFeaturesin anIdentityFeaturesListso subsequent pushes go through the engine's collection.identifier, merges itsidentityFeaturesinto the existing clone instead of replacing it.The original
IdentityModelinstances onenvironment.identityOverridesare left untouched, so engine code that re-reads the environment still sees the raw API payload.How did you test this code?
tests/engine/unit/mappers.test.tscoverage that asserts each unique feature-set hash produces its own identity override segment, including two entries formulti-override-id.tests/sdk/flagsmith.test.ts › test_localEvaluation_true__multiple_identity_overrides_for_same_identifier_merged, which callsgetIdentityFlags('multi-override-id')against a local-evaluation client and verifies bothsome_feature(from the first entry) andmv_feature(from the second entry) resolve to their overridden values and enabled states.tests/sdk/data/environment.jsonwith twomulti-override-identries covering different features so the new tests exercise the merge path.npm testlocally; all suites pass.