Repository navigation
fix(Features): Allow partial updates of segment overrides via the feature states API - #9123
Open
Pranav-Singh-Devloper wants to merge 1 commit into
Conversation
…ture states API
A PATCH to /api/v1/features/featurestates/{id}/ without an environment raised
KeyError: 'environment' (HTTP 500), because FeatureStateSerializerBasic.validate
read it from the serializer context, which this view does not set. Fall back to
the feature state's own environment, and return a validation error instead of
a 500 when no environment is available at all.
Closes Flagsmith#9118
Pranav-Singh-Devloper
requested review from
khvn26
and removed request for
a team
November 26, 2026 13:01
|
@Pranav-Singh-Devloper is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Auto-approval skipped because this PR is from an external contributor.
Re-trigger cubic
This branch has not been deployed
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.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #9118
A partial update (
PATCH) of a segment override through/api/v1/features/featurestates/{id}/returned HTTP 500 withKeyError: 'environment'.FeatureStateSerializerBasic.validate()falls back toself.context["environment"]when the request body has noenvironment, andSimpleFeatureStateViewSetdoesn't put an environment in the context.validate()now falls back to the feature state's own environment on updates. If there is no environment at all (in the body, the context or the instance), it returns a validation error onenvironmentinstead of a 500.No docs change: this restores the documented behaviour of
PATCH.How did you test this code?
test_partial_update_segment_override__without_environment__updates_feature_state:PATCH {"enabled": ...}withMANAGE_SEGMENT_OVERRIDESnow returns 200 and updates the override. Without the fix it fails withKeyError: 'environment'.test_feature_state_serializer_basic__no_environment_anywhere__returns_validation_errorcovers the new error branch.make test opts='tests/unit/features/test_unit_features_views.py tests/unit/features/test_unit_features_serializers.py -k "segment_override or without_environment or no_environment or featurestate or feature_state_serializer"': 33 passed.ruff,ruff format,flagsmith-lint-testsandmypypass on the changed files.PATCHfrom the issue returned 200 and updated the override.