Skip to content

feat(multivariate): thread variant key into the environment document#7699

Merged
gagantrivedi merged 1 commit into
mainfrom
feat/multivariate-key-engine-document
Jun 5, 2026
Merged

feat(multivariate): thread variant key into the environment document#7699
gagantrivedi merged 1 commit into
mainfrom
feat/multivariate-key-engine-document

Conversation

@gagantrivedi
Copy link
Copy Markdown
Member

@gagantrivedi gagantrivedi commented Jun 3, 2026

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature. (deferred — the key isn't consumed by SDKs yet.)
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Builds on #7698. Adds key to the engine MultivariateFeatureOptionModel and passes it through in map_mv_option_to_engine, so each variant's key is included in the environment document — both the SDK local-eval document and the DynamoDB/edge document model_dump() the same EnvironmentModel.

Variant selection is unchanged. Returning the key in SDK/identify responses is a later slice.

Compatibility

  • Old document (no key) → parses, key defaults to None.
  • New document → older readers ignore the unknown field: these pydantic models use the default extra='ignore', and flagsmith-flag-engine types are TypedDicts with no runtime validation.
  • DynamoDB is schemaless — the new attribute is a no-op at the storage layer.

How did you test this code?

New unit tests cover the mapper (key reaches the engine model), the serialised document (key present in model_dump() output), and parsing an older document without key. Edge API integration test snapshots of the DynamoDB identity document were updated to include the field.

Ran the mapper suite and the document consumers (edge_api, environments, util, feature serializers, import/export) locally — all green; ruff/mypy clean.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 5, 2026 7:38am
flagsmith-frontend-preview Ignored Ignored Preview Jun 5, 2026 7:38am
flagsmith-frontend-staging Ignored Ignored Preview Jun 5, 2026 7:38am

Request Review

@github-actions github-actions Bot added api Issue related to the REST API feature New feature or request labels Jun 3, 2026
@gagantrivedi gagantrivedi force-pushed the feat/multivariate-key-engine-document branch from 21137cc to 3fb6448 Compare June 3, 2026 12:20
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 3, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.52%. Comparing base (6fcede7) to head (b0efb54).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7699   +/-   ##
=======================================
  Coverage   98.52%   98.52%           
=======================================
  Files        1445     1445           
  Lines       55061    55083   +22     
=======================================
+ Hits        54251    54273   +22     
  Misses        810      810           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gagantrivedi gagantrivedi force-pushed the feat/multivariate-key-engine-document branch from 3fb6448 to 768a723 Compare June 3, 2026 12:37
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 3, 2026
@gagantrivedi gagantrivedi force-pushed the feat/multivariate-key-engine-document branch from 768a723 to eecc05c Compare June 4, 2026 06:16
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 4, 2026
Base automatically changed from feat/multivariate-option-key to main June 5, 2026 07:06
Add `key` to the engine `MultivariateFeatureOptionModel` and map it through
in `map_mv_option_to_engine`, so the per-variant key flows into both the SDK
local-evaluation document and the DynamoDB/edge document.

The field is optional (defaults to None), mirroring the existing `id` field on
the same model. Adding it is backward- and forward-compatible: consumers parse
these documents with pydantic's default `extra='ignore'`, so a lagging Edge API
reading a newer document silently ignores the unknown field, and new code
reading an older document defaults `key` to None. Two regression tests lock in
this round-trip guarantee.
@gagantrivedi gagantrivedi force-pushed the feat/multivariate-key-engine-document branch from eecc05c to b0efb54 Compare June 5, 2026 07:38
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 5, 2026
@gagantrivedi gagantrivedi marked this pull request as ready for review June 5, 2026 07:39
@gagantrivedi gagantrivedi requested a review from a team as a code owner June 5, 2026 07:39
@gagantrivedi gagantrivedi requested review from emyller and removed request for a team June 5, 2026 07:39
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jun 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-7699 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-7699 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-7699 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-7699 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7699 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7699 Finished ✅ Results

@gagantrivedi
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

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

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 a key field to the MultivariateFeatureOptionModel and updates the engine mapping logic to map this field. Additionally, it updates integration and unit tests to ensure the key field is handled correctly and defaults to None when missing. There are no review comments, so no feedback is provided.

@gagantrivedi gagantrivedi requested a review from Zaimwa9 June 5, 2026 07:45
@gagantrivedi gagantrivedi removed the request for review from emyller June 5, 2026 07:46
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41.3 seconds
commit  b0efb54
info  🔄 Run: #17275 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  44.9 seconds
commit  b0efb54
info  🔄 Run: #17275 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  41.4 seconds
commit  b0efb54
info  🔄 Run: #17275 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  58.8 seconds
commit  b0efb54
info  🔄 Run: #17275 (attempt 1)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Visual Regression

19 screenshots compared. See report for details.
View full report

Copy link
Copy Markdown
Contributor

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@gagantrivedi gagantrivedi merged commit ed18061 into main Jun 5, 2026
48 of 51 checks passed
@gagantrivedi gagantrivedi deleted the feat/multivariate-key-engine-document branch June 5, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants