fix(Utils): add guard against null rule value in validateRule#7779
fix(Utils): add guard against null rule value in validateRule#7779afsuyadi wants to merge 1 commit into
Conversation
|
@afsuyadi is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
3438e22 to
3662bc2
Compare
This comment was marked as spam.
This comment was marked as spam.
Zaimwa9
left a comment
There was a problem hiding this comment.
Thanks for the contribution.
It would be preferable to avoid loosy comparisons if you don't mind.
We have been ramping up on using unit tests on the frontend. validateRule would be a perfect candidate if we could add a couple of parametrized tests around it, including ones validating the fix.
👍
| } | ||
| } | ||
| case 'MODULO': { | ||
| if (rule.value == null) { |
There was a problem hiding this comment.
Actually, let's avoid the loose comparison and keep the !rule.value. From the above (Regex), it hasn't generated an error so there is no reason for now to make a change there
There was a problem hiding this comment.
Okay I'll revert the change. Thanks for the review
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Contributes to #7536
CreateSegmentcomponent is trying to call methodvalidateRule()by passing an object.split()method is executed on a variable that isn't string-type.validateRule(), only value prop that is accessed and doesn't have its own guard, so the method crashes when it's empty (either null or undefined).How did you test this code?
Screencast.from.14-06-26.11.46.58.webm