Sentry: FLAGSMITH-API-69Q (https://flagsmith.sentry.io/issues/7627331389/)
What happens
A PATCH to /api/v1/projects/{project_pk}/features/{feature_pk}/mv-options/{pk}/ that omits feature from the body raises an unhandled KeyError: 'feature' → HTTP 500.
Root cause
MultivariateFeatureOptionSerializer.validate() (api/features/multivariate/serializers.py:83) reads attrs["feature"]:
def validate(self, attrs):
attrs = super().validate(attrs)
total_sibling_percentage_allocation = (
self._get_siblings(attrs["feature"]).aggregate(...)
)
On partial_update, feature is only present in attrs if the client sent it, so any partial PATCH that omits it (e.g. updating only default_percentage_allocation, type, or key) 500s.
Reproduce
PATCH /api/v1/projects/<p>/features/<f>/mv-options/<o>/
{ "default_percentage_allocation": 40 }
→ 500, KeyError: 'feature'
Including "feature": <f> in the body avoids it.
Suggested fix
Fall back to the instance on partial updates:
feature = attrs.get("feature") or getattr(self.instance, "feature", None)
Notes
Surfaced via the Flagsmith CLI (feature variant update sends partial PATCHes). Worked around CLI-side by always sending feature; other clients doing partial PATCHes still hit this.
Sentry: FLAGSMITH-API-69Q (https://flagsmith.sentry.io/issues/7627331389/)
What happens
A
PATCHto/api/v1/projects/{project_pk}/features/{feature_pk}/mv-options/{pk}/that omitsfeaturefrom the body raises an unhandledKeyError: 'feature'→ HTTP 500.Root cause
MultivariateFeatureOptionSerializer.validate()(api/features/multivariate/serializers.py:83) readsattrs["feature"]:On
partial_update,featureis only present inattrsif the client sent it, so any partial PATCH that omits it (e.g. updating onlydefault_percentage_allocation,type, orkey) 500s.Reproduce
Including
"feature": <f>in the body avoids it.Suggested fix
Fall back to the instance on partial updates:
Notes
Surfaced via the Flagsmith CLI (
feature variant updatesends partial PATCHes). Worked around CLI-side by always sendingfeature; other clients doing partial PATCHes still hit this.