balderdashy/sails — pull request #2482 by askmike (2014-12-10 10:01:39+00:00)
Title: catch undefined child pk in blueprints/remove

If you don't specify a child PK in the remove call (to remove an assocation), sails will crash. Example:

io.socket.delete('/user/1/pets/') // note the missing pet ID

Will result in:
/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/remove.js:205
if(key.toString() !== '[object Object]') validAssociation = true;
^
TypeError: Cannot call method 'toString' of undefined
at Remove.validatePrimaryKey (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/remove.js:205:10)
at Remove.removeRecord (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/remove.js:133:34)
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/remove.js:114:10
at replenish (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:194:21)
at /usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:211:15
at Object.async.eachLimit (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:171:12)
at Remove.removeAssociations (/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/remove.js:113:9)
at /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/remove.js:81:10
at iterate (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:149:13)
at Object.async.eachSeries (/usr/local/lib/node_modules/sails/node_modules/waterline/node_modules/async/lib/async.js:165:9)