Throws parameter mismatch error #25

Open
fizerkhan opened this Issue Jan 21, 2013 · 7 comments

Projects

None yet

4 participants

@fizerkhan

var acl = require('acl');

// Using the memory backend
acl = new acl(new acl.memoryBackend());

acl.allow([{roles:['guest','member'],
allows:[
{resources:'blogs', permissions:'get'},
{resources:['forums','news'], permissions:['get','put','delete']}]
},
{roles:['gold','silver'],
allows:[
{resources:'cash', permissions:['sell','exchange']},
{resources:['account','deposit'], permissions:['put','delete']}]
}
]);

It throws

Parameter missmatch.
Input:
( [object Object],[object Object]{array} )
Accepted:
([object Arguments])
([object Arguments])

throw new Error('Broke parameter contract');
@manast manast was assigned Jan 30, 2013
@tthew
Contributor
tthew commented Jun 12, 2013

Any update on this? The README examples do not work at all.

@tthew
Contributor
tthew commented Jun 12, 2013

e.g:

var acl = require('acl')

    acl = new acl(new acl.memoryBackend());
    acl.allow('guest', 'blogs', 'view');

and

var acl = require('acl')
   , redis = require('redis')
   , client = redis.createClient() ;

    acl = new acl(new acl.redisBackend(client));
    acl.allow('guest', 'blogs', 'view');

Both produce:

Parameter missmatch.
Input:
( guest{string} blogs{string} view{string} )
Accepted:
([object Arguments])
([object Arguments])
@manast
Member
manast commented Jun 12, 2013

Check this: https://github.com/OptimalBits/node_acl#allow

For simplicity the examples do not include the mandatory callback with the result of the operation.

@talentedmrjones

@manast We don't need the examples to be simple, we need them to be accurate and thorough. I've been tripped up by the cryptic "broke parameter contract" errors simply because I pasted the example verbatim.

Furthermore, the documentation says:

"All the following functions return a promise or optionally take a callback with an err parameter as last parameter. "

But as I and others on this comment have seen, the callback is not optional.

Also, "Accepted:([object Arguments])" is not very helpful.

Shall I update the examples, provide a more helpful error, and submit a pull request?

@manast
Member
manast commented Mar 26, 2014

you are welcome to correct any inaccuracies, but I am not sure the documentation is wrong nor that the examples work, check for example this:
https://github.com/OptimalBits/node_acl/blob/master/lib/acl.js#L215-L221
All methods return promises now, so the callback must be optional...

@manast
Member
manast commented Mar 26, 2014

I have actually discovered that the version in npm is older than the one in github...

@manast
Member
manast commented Mar 26, 2014

I have published it now. note that it is a 0.x update, which means changes in the API according to semver standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment