-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: saveSettings endpoint allowing NaN to be stored on Int settings #32428
base: develop
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 8ae7fea The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #32428 +/- ##
========================================
Coverage 56.38% 56.39%
========================================
Files 2434 2433 -1
Lines 53693 53703 +10
Branches 11050 11061 +11
========================================
+ Hits 30275 30284 +9
+ Misses 20779 20776 -3
- Partials 2639 2643 +4
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add an API end-to-end test for this? I believe you could use the settings/:_id
POST endpoint
@@ -83,6 +83,12 @@ Meteor.methods<ServerMethods>({ | |||
break; | |||
case 'int': | |||
check(value, Number); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this fail if value is an empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I am still curious, how can "value" be NaN for an empty string, after getting serialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I see it, client doesn't just serialize as is.
according to ejson code, while not possible through UI, but is if somebody manually sends Infinity.
suggest using Number.isFinite instead, wdyt @MarcosSpessatto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@KevLehman not sure if this is resolved yet 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the value is fetched from db, and looks like can possibly be NaN. this tells me the save action is what should always set empty number setting type values to zero, and not be handled as an exception for this specific method.
please help me if I'm missing something.
nvm I was rushing my review and misread, sorry.
CORE-418
Fixes issue that allowed empty strings to be saved in the int settings, causing an NaN value on the DB