vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
385 stars 68 forks source link

Data object that has a property named nodeType causes exception in Meteor 1.3+ #180

Closed xc8tlik closed 8 years ago

xc8tlik commented 8 years ago

Code to reproduce:

var job = new Job(MyJobs, 'myQueue', {
  nodeType: "This will cause 'Error: Match error: Expected plain object in field data' :(",
});

Example error message:

I20160428-09:16:02.865(1)? Thu Apr 28 2016 09:16:02 GMT+0100 (BST), [SERVER], jobSave, Error: Match error: Expected plain object in field data
I20160428-09:16:03.223(1)? Exception while invoking method 'startNodes' Error: Match error: Expected plain object in field data
I20160428-09:16:03.223(1)?     at meteorInstall.node_modules.meteor.check.match.js.exports.check (packages/check/match.js:34:1)
I20160428-09:16:03.223(1)?     at JobCollectionBase._DDPMethod_jobSave (packages/vsivsi_job-collection/src/shared.coffee:782:5)
I20160428-09:16:03.224(1)?     at JobCollection._methodWrapper (packages/vsivsi_job-collection/src/server.coffee:147:22)
I20160428-09:16:03.224(1)?     at packages/vsivsi_job-collection/src/server.coffee:85:40
I20160428-09:16:03.224(1)?     at methodCall (packages/vsivsi_job-collection/job/src/job_class.coffee:19:18)
I20160428-09:16:03.224(1)?     at Job.save (packages/vsivsi_job-collection/job/src/job_class.coffee:780:12)
I20160428-09:16:03.224(1)?     at [object Object].<anonymous> (project.js:233:33)
I20160428-09:16:03.224(1)?     at [object Object].$$.fn.eles.each (/home/user/project/.meteor/local/build/programs/server/packages/maxkfranz_cytoscape.js:13829:24)
I20160428-09:16:03.225(1)?     at [object Object].startNodes (project.js:209:13)
I20160428-09:16:03.225(1)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)
I20160428-09:16:03.242(1)? Sanitized and reported to the client as: Match failed [400]

Root cause:

_DDPMethod_jobSave()/check() > testSubtree() > isPlainObject() > check in if statement for obj.nodeType

Suggested solution:

Easiest thing to do is document that you can't have a nodeType property in the data object. Maybe this is such an unlikely scenario that you don't want to overcomplicate the docs or code?

Either way, thought I would bring it to your attention! Feel free to close.

vsivsi commented 8 years ago

Hi, thanks for the thorough and well researched issue report. This is a Meteor issue. They implemented their check function that way... I'm sure there must be some good reason. This issue will likely affect all apps/packages that implement Meteor methods and do proper argument type checking... It's a pretty obscure problem, but if there is going to be a change, it should probably be in the Meteor codebase.

xc8tlik commented 8 years ago

Agreed, if nothing else perhaps this will help any late-night Googlers in future. Thanks for all your good work.