You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Setting data to undefined using postgres causes parse server to crash #5065
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.
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 undefined value) with the new properties that I defined (all of these have truthy values).
@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 undefined properties, it was user error in this case. 😃
Still I think it would be good to handle undefined in the same way as null to avoid this kind of problem in the future - saving a property as undefined using mongodb works fine.
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.
Activity
flovilmart commentedon Sep 19, 2018
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.
flovilmart commentedon Sep 19, 2018
Can you provide a request example with the undefined in it?
ben-eb commentedon Sep 19, 2018
@flovilmart The unusual thing is that I'm not saving the
undefinedwith my object; the code looks something like this: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
undefinedvalue) with the new properties that I defined (all of these have truthy values).flovilmart commentedon Sep 19, 2018
Can you provide the logs when running with VERBOSE=1?
ben-eb commentedon Sep 20, 2018
@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
undefinedproperties, it was user error in this case. 😃Still I think it would be good to handle
undefinedin the same way asnullto avoid this kind of problem in the future - saving a property asundefinedusing mongodb works fine.flovilmart commentedon Sep 20, 2018
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.
ben-eb commentedon Sep 20, 2018
@flovilmart Sure thing, it's easily reproducible with this handler:
Output:
flovilmart commentedon Sep 20, 2018
Are you willing to open a PR with the fix? This seems straightforward now. Undefined values should be skipped
Sent with GitHawk
ben-eb commentedon Sep 20, 2018
@flovilmart Yes, see #5069.
postgres: Ensure that setting a value to undefined is a no-op on writ…
postgres: Ensure that setting a value to undefined is a no-op on writ…