fix: feature_segment missing in versioning#7618
Conversation
|
@SahilJat 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.
Code Review
This pull request fixes a potential KeyError (which resulted in a 500 Internal Server Error) when the feature_segment key is entirely omitted from the feature_states_to_create payload. By using .get("feature_segment") instead of direct key access, the code now safely handles missing keys. A unit test has also been added to verify that a 400 Bad Request is returned instead of a 500 error. I have no further feedback to provide as the changes are correct and well-tested.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7618 +/- ##
==========================================
- Coverage 98.51% 98.36% -0.16%
==========================================
Files 1439 1439
Lines 54690 54577 -113
==========================================
- Hits 53880 53685 -195
- Misses 810 892 +82 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks @SahilJat ! |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #7587
Fixes a 500 error that occurs when
feature_segmentis completely missing fromfeature_states_to_create.Swapped
fs["feature_segment"]forfs.get("feature_segment")insegment_ids_to_create_overridesto safely handle missing keys and preventKeyErrorcrashes. The existing validation now correctly catches this and returns a 400.How did you test this code?
Added a test case verifying that a payload entirely missing the
feature_segmentkey returns a 400 with the proper error message instead of a 500.