Skip to content

Fix issue when MongoTransform converts object-type field with null values #2029

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

Merged

Conversation

yuzeh
Copy link
Contributor

@yuzeh yuzeh commented Jun 10, 2016

I've been getting gnarly errors when issuing the following request in cURL (to a server running parse-server 2.2.12):

➜ Dan@Dans-MacBook-Pro  ~/MTailor/workspace/parse-server git:(MongoTransform-obj-with-null-values) curl -X POST \
-H "X-Parse-Application-Id: <REDACTED>" \
-H "X-Parse-REST-API-Key: <REDACTED>" \
-H "X-Parse-Master-Key: <REDACTED>" \
-H "Content-Type: application/json" \
-d '{ "orderFormObject": {"nest1": null, "nest2": {"blah": 1}}}' \
https://<REDACTED>/parse/classes/OrderItem
{"code":1,"message":"Internal server error."}%

The trace looks like this:

ESC[31merrorESC[39m: Uncaught internal server error. [TypeError: Cannot convert undefined or null to object] TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at transformInteriorValue (/var/app/current/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:104:100)
    at /var/app/current/node_modules/parse-server/node_modules/lodash/lodash.js:12739:23
    at /var/app/current/node_modules/parse-server/node_modules/lodash/lodash.js:4411:15
    at baseForOwn (/var/app/current/node_modules/parse-server/node_modules/lodash/lodash.js:2654:24)
    at Function.mapValues (/var/app/current/node_modules/parse-server/node_modules/lodash/lodash.js:12738:7)
    at parseObjectKeyValueToMongoObjectKeyValue (/var/app/current/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:296:28)
    at parseObjectToMongoObjectForCreate (/var/app/current/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:308:33)
    at MongoStorageAdapter.createObject (/var/app/current/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoStorageAdapter.js:242:79)
    at /var/app/current/node_modules/parse-server/lib/Controllers/DatabaseController.js:518:29
    at run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22)
    at /var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28
    at flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
    at nextTickCallbackWith0Args (node.js:419:9)
    at process._tickDomainCallback (node.js:389:13)

This change should fix the issues I've been having.

@codecov-io
Copy link

codecov-io commented Jun 10, 2016

Current coverage is 91.92%

Merging #2029 into master will not change coverage

@@             master      #2029   diff @@
==========================================
  Files            91         91          
  Lines          6431       6431          
  Methods        1099       1099          
  Messages          0          0          
  Branches       1350       1350          
==========================================
  Hits           5912       5912          
  Misses          519        519          
  Partials          0          0          

Powered by Codecov. Last updated by a00d795...f7130a0

@drew-gross drew-gross merged commit 11301d9 into parse-community:master Jun 10, 2016
@yuzeh yuzeh deleted the MongoTransform-obj-with-null-values branch June 10, 2016 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants