-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Setting data to undefined using postgres causes parse server to crash #5065
Comments
Thanks for reporting the issue. We encourage you to migrate to version 3.0. In the meantime, I’m not sure how you are sending undefined. To remove a value use the {_op: Delete} instead. |
Can you provide a request example with the undefined in it? |
@flovilmart The unusual thing is that I'm not saving the const Question = Parse.Object.extend('Question')
const save = (request, response) => {
return Promise.resolve(request.params.id)
.then(id => id ? new Parse.Query(Question).get(id) : new Question())
.then(question => {
question.set(request.params);
return question.save();
})
.then(question => response.success(question))
} I checked which parameters that Parse was trying to save and it seems like it was trying to merge the existing object (which had an |
Can you provide the logs when running with VERBOSE=1? |
@flovilmart I think I found my issue, the property was being set in a before save hook; I added an extra guard to that to ensure that the transform only applies when the property is a string type. That resolves my issue, so I don't think Parse is trying to save Still I think it would be good to handle |
But undefined should not reach mongodb, the ‘undefined’ type is not supported by Parse server. Only the delete operator is. Can you write the test that shows the error pleaee? Because I still cannot understand why undefined reached the server while all payloads are serialized via JSON which strips undefined. Also, please provide the logs when running with VERBOSE. |
@flovilmart Sure thing, it's easily reproducible with this handler: Parse.Cloud.beforeSave('Question', (request, response) => {
request.object.set('crash', undefined);
return response.success(request.object)
}); Output:
|
Are you willing to open a PR with the fix? This seems straightforward now. Undefined values should be skipped Sent with GitHawk |
@flovilmart Yes, see #5069. |
Issue Description
When updating an existing record, sending the value
undefined
will cause parse-server to crash, but when the value isnull
, it's OK.I traced the problem down to these locations:
I would expect the simple fix would be to do this instead:
Steps to reproduce
undefined
.Expected Results
Parse should not throw an exception on
undefined
values.Actual Outcome
Parse is throwing an exception when saving
undefined
values.Environment Setup
Server
Database
Logs/Trace
Is there any support still for the v2 releases? We're still relying on these for production instances - backporting a fix would be most welcomed.
The text was updated successfully, but these errors were encountered: