Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
657 stars 92 forks source link

exception from sub id ... #143

Closed greenwolfe closed 7 years ago

greenwolfe commented 9 years ago

I am getting the following error, which seems related to something in collection hooks and I can't figure it out.

I20150815-11:46:11.903(-4)? Exception from sub walls id pB9xvAkv5DQmRmYdL Error: Match error: Expected string, got object I20150815-11:46:11.920(-4)? at checkSubtree (packages/check/match.js:220:1) I20150815-11:46:11.919(-4)? at [object Object].condition (app/methods/MatchHelpers.js:2:5) I20150815-11:46:11.917(-4)? at checkSubtree (packages/check/match.js:159:1) I20150815-11:46:11.918(-4)? at check (packages/check/match.js:32:1) I20150815-11:46:11.920(-4)? at check (packages/check/match.js:32:1) I20150815-11:46:11.920(-4)? at [object Object].Meteor.publish.Columns.find.wallID (app/server/publications.js:79:3) I20150815-11:46:11.922(-4)? at packages/matb33:collection-hooks/collection-hooks.js:218:1 I20150815-11:46:11.923(-4)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1) I20150815-11:46:11.923(-4)? at [object Object]._handler (packages/matb33:collection-hooks/collection-hooks.js:217:1) I20150815-11:46:11.923(-4)? at packages/check/match.js:109:1 I20150815-11:46:11.924(-4)? Sanitized and reported to the client as: Match failed [400] I20150815-11:46:11.926(-4)?

The id given in the error message (pB9xvAkv5DQmRmYdL) does not occur anywhere in my database as far as I can tell.

at app/server/publications:79:3 I have

Meteor.publish('walls',function(studentID,activityID) {  
  check(studentID,Match.Optional(Match.OneOf(Match.idString,null))); 
  check(activityID,Match.idString); 

Line 79 is the last line above.

There's only one subscription call to this publish function:

var activityID = FlowRouter.getParam('_id');
if ((studentID) && (activityID))
  Meteor.call('addDefaultWalls',studentID,activityID);

I have also checked student ID and I am definitely passing in an id string and not an object.

As far as as [object Object].Meteor.publish.Columns.find.wallID. I have

app/server/publications starting at :99

Meteor.publish('columns',function(wallID) {  
  check(wallID,Match.idString);
  return Columns.find({wallID:wallID});
});

There is also only one subscription call to this publish function

  instance.autorun(function() {
    var columnSubscription = instance.subscribe('columns', instance.data._id);
  });

I have checked instance.data._id and it is a valid id string and not an object.

At app/methods/MatchHelpers.js:2:5 I have:

Match.idString = Match.Where(function (id) {
    check(id, String);
    return /^[a-zA-Z0-9]{17}$/.test(id);
/*^         start of string
[a-zA-Z0-9]  a or b or c or ... z or A or B or C ... Z or 0 or 1 or ... 9
{17}        exactly 17 times (+ would mean any number of times, including 0, * would mean any       number of times greater than 0
$         end of string*/
});

Is this something in collection hooks as it appears, or have I done something wrong? My code appears to run properly despite the error. Any help understanding and resolving it is appreciated.

matb33 commented 9 years ago

I'll have to take a close look at this. You're not the first to report an issue with regards to check and collection-hooks. There's most likely nothing wrong with your code.

pcuci commented 9 years ago

+1 Thx!

funkybunky commented 8 years ago

any news on this?

funkybunky commented 8 years ago

sorry for bumping, it was my fault. used check('nameOfParam', pattern) instead of check(nameOfParam, pattern)

gkrizek commented 8 years ago

Any news on this? I'm still getting it and don't quite get why. I'm not doing any checks on the Publication.

I20160817-05:46:51.308(-6)? Exception from sub chat id yd2sPdbCA5tTMWZmE Error: Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation
I20160817-05:46:51.310(-6)?     at exports.check (packages/check/match.js:34:1)
I20160817-05:46:51.310(-6)?     at [object Object]._getFindOptions (packages/mongo/collection.js:277:7)
I20160817-05:46:51.310(-6)?     at [object Object].find (packages/mongo/collection.js:316:39)
I20160817-05:46:51.310(-6)?     at Subscription.<anonymous> (server/server.js:9:17)
I20160817-05:46:51.310(-6)?     at packages/matb33_collection-hooks/collection-hooks.js:281:1
I20160817-05:46:51.311(-6)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20160817-05:46:51.311(-6)?     at Subscription._handler (packages/matb33_collection-hooks/collection-hooks.js:280:1)
I20160817-05:46:51.311(-6)?     at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1711:12)
I20160817-05:46:51.311(-6)?     at Subscription._runHandler (packages/ddp-server/livedata_server.js:1026:17)
I20160817-05:46:51.311(-6)?     at Session._startSubscription (packages/ddp-server/livedata_server.js:845:9)
I20160817-05:46:51.315(-6)? Sanitized and reported to the client as: Match failed [400]
I20160817-05:46:51.316(-6)?
gkrizek commented 8 years ago

I'm finding that it only gives this error if you have a limit in your query. When I take out the limit, it works just fine.

I also just uninstalled your package and tried it again and I get the same error, so I don't think it has anything to do with your package after all. It just references it in the stack trace because it is tied into collections. I'll try to narrow down what's causing this.

My pub for the sake of documentation.

Meteor.publish("chat", function (lng, lat, limit) {
    return Chat.find({loc: {$geoWithin:{$center: [[lng, lat], 20]}}}, {limit: limit}, {fields: {'_id': 1, 'sender': 1, 'message': 1, 'createdAt': 1}});
});
zimme commented 7 years ago

So it seems that both the issues in here was coding mistakes so I'm closing this.