Skip to content

feat: surface the selected variant on flags#221

Merged
gagantrivedi merged 1 commit into
mainfrom
feat/multivariate-variant
Jun 9, 2026
Merged

feat: surface the selected variant on flags#221
gagantrivedi merged 1 commit into
mainfrom
feat/multivariate-variant

Conversation

@gagantrivedi

@gagantrivedi gagantrivedi commented Jun 9, 2026

Copy link
Copy Markdown
Member

Adds Flag.variant — which multivariate variant an identity was bucketed into:

  • the variant's key when a named variant is selected,
  • "control" for the control bucket,
  • None otherwise (standard feature, unkeyed variant, or no identity).

Threads the variant key from the environment document through the evaluation context so the engine returns it. Flag.from_api_flag reads it too, so remote evaluation populates it once the API returns it. Bumps flagsmith-flag-engine to ^10.2.0.

@gagantrivedi gagantrivedi requested a review from a team as a code owner June 9, 2026 08:55
@gagantrivedi gagantrivedi requested review from emyller and removed request for a team June 9, 2026 08:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for variant keys in multivariate feature options. It updates the MultivariateFeatureOptionModel type definition, maps the variant key in flagsmith/mappers.py when present, and adds a variant field to the Flag model, populated from evaluation results and API flags. Additionally, the flagsmith-flag-engine dependency is updated to 10.2.0, and corresponding unit tests are introduced. The feedback suggests adding a unit test to explicitly verify that null variant keys are correctly dropped to prevent future regressions.

Comment thread tests/test_mappers.py
In local evaluation, expose which multivariate variant an identity was
bucketed into via a new `Flag.variant`:

- the variant's key when a named variant is selected,
- "control" when the identity falls in the control bucket,
- None otherwise (standard feature, unkeyed variant, or no identity).

Threads the variant key from the environment document through the
evaluation context so the engine can return it, and surfaces the engine's
`variant` on the Flag. Requires flag-engine >=10.2.0.

`Flag.from_api_flag` reads `variant` too, so remote evaluation will
populate it once the API returns it.
@gagantrivedi gagantrivedi force-pushed the feat/multivariate-variant branch from e50ada6 to f15af26 Compare June 9, 2026 09:20
@gagantrivedi gagantrivedi requested a review from Zaimwa9 June 9, 2026 09:31
@gagantrivedi gagantrivedi removed the request for review from emyller June 9, 2026 09:31
@gagantrivedi gagantrivedi merged commit 7fc7224 into main Jun 9, 2026
7 checks passed
@gagantrivedi gagantrivedi deleted the feat/multivariate-variant branch June 9, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants