How are you running Flagsmith
Describe the bug
When a feature state ends up with MultivariateFeatureStateValue.percentage_allocation rows summing to more than 100%, process_environment_update fails when map_feature_state_to_engine raises a Pydantic ValidationError from FeatureStateModel. While that state persists, the environment document on DynamoDB is never rewritten, so the Edge API keeps serving the previous value of every flag in that environment regardless of what the dashboard shows.
Acceptance criteria
- It is not possible to leave a feature state's
MultivariateFeatureStateValue.percentage_allocation rows summing to more than 100% in the database, by any means.
How to reproduce
There is one observed case in production, with unclear reproduction steps. I was able to reproduce it in the API via mv-options:
- Pick a feature whose env-default feature state already has multivariate percentage allocations summing to 100%.
POST /api/v1/projects/<project_id>/features/<feature_id>/mv-options/ with a body whose default_percentage_allocation is greater than zero.
GET /api/v1/environments/<environment_api_key>/featurestates/?feature=<feature_id> and observe the env-default feature state's multivariate_feature_state_values now summing to more than 100%.
In the above screenshot, the dashboard displays the faulty MV setup, with an error message, when it already exists.
How are you running Flagsmith
Describe the bug
When a feature state ends up with
MultivariateFeatureStateValue.percentage_allocationrows summing to more than 100%,process_environment_updatefails whenmap_feature_state_to_engineraises a PydanticValidationErrorfromFeatureStateModel. While that state persists, the environment document on DynamoDB is never rewritten, so the Edge API keeps serving the previous value of every flag in that environment regardless of what the dashboard shows.Acceptance criteria
MultivariateFeatureStateValue.percentage_allocationrows summing to more than 100% in the database, by any means.How to reproduce
There is one observed case in production, with unclear reproduction steps. I was able to reproduce it in the API via
mv-options:POST /api/v1/projects/<project_id>/features/<feature_id>/mv-options/with a body whosedefault_percentage_allocationis greater than zero.GET /api/v1/environments/<environment_api_key>/featurestates/?feature=<feature_id>and observe the env-default feature state'smultivariate_feature_state_valuesnow summing to more than 100%.In the above screenshot, the dashboard displays the faulty MV setup, with an error message, when it already exists.