sebelga / gstore-node

Google Datastore Entities Modeling for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'Symbol(KEY)' when body is null or undefined

Startouf opened this issue · comments

I have an enigmatic error when trying to receive a POST request containing several fields and some nested fields. It's most likely an error in the modelling (I will write a comment when I find out the mistake I made), but this deserves a better error message that would ideally help understand what is wrong in the model.

Backtrace

backend     | TypeError: Cannot read property 'Symbol(KEY)' of undefined
backend     |     at Function.sanitize (/app/node_modules/gstore-node/lib/model.js:377:33)
backend     |     at createEvent (/app/src/controllers/api/v1/events.controller.ts:27:28)

gstore-node 7.2.5

EDIT : I had made again the noob mistake of forgetting to add the bodyparser.json() middleware to my express stack. Adding an error message when the body received is null could help those devs who are floating off in their own thoughts like me.