feat(sdk): add variant key to evaluation schemas#7704
Draft
gagantrivedi wants to merge 1 commit into
Draft
Conversation
Add an optional `key` to FeatureValue in the evaluation context schema, and an optional `variant` to FlagResult in the evaluation result schema, so engines can report which multivariate variant was selected. The `variant` name follows OpenFeature's ResolutionDetails.variant. Both fields are omitted when not applicable, consistent with the existing optional fields in these schemas.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
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.
docs/if required so people know about the feature. (deferred — SDK-facing docs land with the SDK slice.)Changes
Contributes to
Extends the canonical cross-SDK evaluation contract so engines can report which multivariate variant was selected:
sdk/evaluation-context.json—FeatureValuegains an optionalkey: a stable, human-readable identifier for the variant, fed into evaluation from the environment document (see feat(multivariate): thread variant key into the environment document #7699).sdk/evaluation-result.json—FlagResultgains an optionalvariant: the selected variant's key. The name follows OpenFeature'sResolutionDetails.variant("a semantic identifier for a value"), so OpenFeature providers map it 1:1.Both fields are omitted when not applicable (no variant selected, or the selected variant has no key), consistent with the existing optional fields (
metadata,variants,priority) in these schemas. Purely additive — existing consumers are unaffected.Downstream consumers regenerated from these schemas:
flag_engine/context/types.pyandflag_engine/result/types.pyin [flagsmith-engine] (PR to follow), then each SDK.How did you test this code?
datamodel-code-generator(0.33.0, as used by flagsmith-engine) against the updated schemas to confirm the emitted types are the expectedkey: NotRequired[str]/variant: NotRequired[str].