fix(schemas): preserve multivariate option key in DynamoDB document#242
Merged
gagantrivedi merged 1 commit intoJun 30, 2026
Merged
Conversation
The MultivariateFeatureOption TypedDict only declared id and value, so validating the environment document against EnvironmentCompressed dropped the variant key during DynamoDB compression. Add the key field so it survives serialisation to the environment document.
There was a problem hiding this comment.
Code Review
This pull request adds an optional key field (NotRequired[str | None]) to the MultivariateFeatureOption TypedDict in the DynamoDB schema, representing a stable, human-readable identifier for multivariate feature variants. Additionally, an integration test has been added to verify that the key field is correctly validated and preserved. There are no review comments, so I have no feedback to provide.
Zaimwa9
approved these changes
Jun 30, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #242 +/- ##
=======================================
Coverage 97.39% 97.40%
=======================================
Files 104 104
Lines 4613 4619 +6
=======================================
+ Hits 4493 4499 +6
Misses 120 120 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
When a multivariate option is created with a
key, the key is correctly threaded into the engine model (MultivariateFeatureOptionModel.key) inflagsmithcore, but it never reaches the DynamoDB environment document. Documents end up like:— no
key.Root cause
The environment document is validated against
EnvironmentCompressedduring compression (map_environment_to_compressed_environment_document→TypeAdapter(EnvironmentCompressed).validate_python(...)). TheMultivariateFeatureOptionTypedDict here only declaredidandvalue, so Pydantic silently dropped the extrakeykey during validation.Fix
Add
key: NotRequired[str | None]to theMultivariateFeatureOptionTypedDict so it survives serialisation. Nullable + not-required keeps backward compatibility with documents written before keys existed.Testing
keyis preserved throughTypeAdapter(MultivariateFeatureOption).validate_python(...).flagsmithcore (test_map_environment_to_compressed_environment_document__mv_option_with_key__key_preserved), which will pass once this is released and the dependency bumped.