feat: include selected variant key in flag results#314
Open
gagantrivedi wants to merge 1 commit into
Open
Conversation
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 871d63c |
a293154 to
1f12564
Compare
4 tasks
1f12564 to
8694ce4
Compare
a34303f to
8bd1ce1
Compare
8bd1ce1 to
9f61777
Compare
Every flag result now carries a `variant` field, mirroring OpenFeature's `ResolutionDetails.variant` (always present, nullable): - the variant's key when a named multivariate variant is selected, - `"control"` when an identity falls in the control bucket (the leftover allocation that resolves to the feature's default value); the control is not a multivariate option, so the engine synthesises this key, - `null` otherwise (standard features, unkeyed variants, or evaluation without an identity, where nothing is bucketed). Selection logic, hashing and ordering are unchanged. The behaviour is covered by the shared engine-test-data corpus, bumped to v3.9.0.
9f61777 to
871d63c
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.
Changes
Every flag result now carries a
variantfield, mirroring OpenFeature'sResolutionDetails.variant(always present, nullable):"control"when an identity falls in the control bucket (the leftover allocation100 − Σ weightsthat resolves to the feature's default value) — the control is not a multivariate option, so the engine synthesises this key,nullotherwise — a standard feature, an unkeyed variant, or evaluation without an identity (nothing is bucketed).{ "name": "checkout_button", "enabled": true, "value": "blue", "reason": "SPLIT; weight=30", "variant": "v_a" } { "name": "checkout_button", "enabled": true, "value": "blue", "reason": "DEFAULT", "variant": "control" } { "name": "basic_flag", "enabled": false, "value": "", "reason": "DEFAULT", "variant": null }Selection logic, hashing and ordering are unchanged.
feat:commit → release-please cuts a minor (10.2.0).Files
flag_engine/context/types.py(generated):FeatureValuegainskey: NotRequired[str]flag_engine/result/types.py(generated):FlagResult.variant: Optional[str](required, nullable)flag_engine/segments/evaluator.py: singlevariantvalue threaded through one result construction.gitmodules+ submodule: corpus bumped to v3.9.0Test coverage
The behaviour is covered end-to-end by the shared engine-test-data corpus (v3.9.0), so the variant-specific unit test was dropped as redundant:
variantnullnullSPLITcases)"control"Landed dependencies
variantrequired + nullable (merged).varianton every result + the keyed-variant case, released as v3.9.0 (merged); submodule pins the tag.How did you test this code?
Full suite 382 passed against the released v3.9.0 corpus.
mypy(strict),black,flake8,isortclean. Generated types verified withdatamodel-code-generator0.33.0 against the merged schema.Cross-engine note
flagsmith-rust-flag-enginepins an older corpus tag and is unaffected until it adopts v3.9.0; the keyed-variant case is what will catch key passthrough not being implemented there.