Skip to content

Commit fba752b

Browse files
authored
Release 1.6.3 (#94)
* Release 1.6.3 * fix(fs/schema): only run validation if field is present (#93)
1 parent 20d1033 commit fba752b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

flag_engine/features/schemas.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ def make_feature_state(self, data, **kwargs) -> FeatureStateModel:
6969
def validate_percentage_allocations(self, data, **kwargs):
7070
"""Since we do support modifying percentage allocation on a per identity override bases
7171
we need to validate the percentage before building the document(dict)"""
72+
# Since client(s) can exclude this field from dumping we need to make sure
73+
# We only run the validation if the field is present on the serializer
74+
if "multivariate_feature_state_values" not in self.fields:
75+
return data
76+
7277
total_allocation = sum(
7378
mvfsv["percentage_allocation"]
7479
for mvfsv in data["multivariate_feature_state_values"]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="flagsmith-flag-engine",
5-
version="1.6.2",
5+
version="1.6.3",
66
author="Flagsmith",
77
author_email="[email protected]",
88
packages=find_packages(include=["flag_engine", "flag_engine.*"]),

tests/unit/features/test_schemas.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,14 @@ def test_dumping_fs_schema_works_for_valid_allocation():
4646
}
4747
# Then
4848
FeatureStateSchema().dump(data)
49+
50+
51+
def test_can_dump_featurestate_schema_without_mvfs(feature_1):
52+
# Given
53+
raw_data = {"feature_state_value": "value"}
54+
# When
55+
dumped_data = FeatureStateSchema(
56+
exclude=["multivariate_feature_state_values"]
57+
).dump(raw_data)
58+
# Then
59+
assert raw_data["feature_state_value"] == dumped_data["feature_state_value"]

0 commit comments

Comments
 (0)