Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR wrong number of arguments for 'hmset' command #262

Closed
yuri-karadzhov opened this issue Sep 6, 2012 · 11 comments
Closed

ERR wrong number of arguments for 'hmset' command #262

yuri-karadzhov opened this issue Sep 6, 2012 · 11 comments
Labels

Comments

@yuri-karadzhov
Copy link

after npm update the problem appear with node-redis

node_redis: no callback to send error: Error: ERR wrong number of arguments for 'hmset' command

/var/www/node_modules/redis/index.js:475
throw err;
^
Error: Error: ERR wrong number of arguments for 'hmset' command
at HiredisReplyParser.RedisClient.init_parser (/var/www/node_modules/redis/index.js:253:27)
at HiredisReplyParser.EventEmitter.emit (events.js:88:17)
at HiredisReplyParser.execute (/var/www/node_modules/redis/lib/parser/hiredis.js:41:18)
at RedisClient.on_data (/var/www/node_modules/redis/index.js:440:27)
at Socket. (/var/www/node_modules/redis/index.js:70:14)
at Socket.EventEmitter.emit (events.js:88:17)
at TCP.onread (net.js:395:14)

I have node 0.8.8 and npm 1.1.59

@yuri-karadzhov
Copy link
Author

I found, that it is caused by local problem with project code, but the error message is really not obvious.

@DTrejo
Copy link
Contributor

DTrejo commented Sep 7, 2012

Would you mind saying what the problem was? I'd be happy to make the error
message more informative.

Cheers
On Sep 6, 2012 5:48 PM, "Yuri Karadzhov" notifications@github.com wrote:

I found, that it is caused by local problem with project code, but the
error message is really not obvious.


Reply to this email directly or view it on GitHubhttps://github.com//issues/262#issuecomment-8348897.

@yuri-karadzhov
Copy link
Author

I'm not really sure, but as I understand the problem was - node use precompiled version of the project to run. As I delete app.js.orig file it start workine just fine. But it still looks like a mistics for me.

In the old version of app.js I use redis call to hash and pass an object as a parametr, but the problem was - the object has some undefined fields and it cause similar problem with redis-client. The error message was informative and show me the stack which leads to that redis call.

Then I fixed this problem by removing this empty fields from th object. And I get the problem discribed above.

@Mikt25
Copy link

Mikt25 commented Jun 13, 2013

One way for this error to occur is passing an integer as the first parameter of hmset. I fixed this by converting the first parameter to a string in my code.

Maybe node_redis should do this automatically if the first parameter is a number?

@nabeelio
Copy link

This is what I'm getting, not sure what I'm doing wrong. Redis docs didn't say if the key had to exist previously, so I don't think that should matter. The command works in redis-cli

// opts.value = { ... };
return redis.hmset(key, opts.value);


TRACE:09:23:52:Sending to Redis: hmset token:8659171012f5422aac2f7777890eb6e8 "id" "8659171012f5422aac2f7777890eb6e8" "value" "5hJPYT2rPSUnbfSms7bFuNgwCvo" "ttl" "86400" - lib/redis::bind
     lib/redis::bind
     lib/redis::bind
send redis-d001.liveclips.net:6379 id 1: *3
$5
hmset
$38
token:8659171012f5422aac2f7777890eb6e8
$91
"id" "8659171012f5422aac2f7777890eb6e8" "value" "5hJPYT2rPSUnbfSms7bFuNgwCvo" "ttl" "86400"

send_command buffered_writes: 0  should_buffer: false
net read redis-d001.liveclips.net:6379 id 1: -ERR wrong number of arguments for 'hmset' command

Can't send an object - so I'm converting the object to the key value pairs, and still doesn't work:

var args = [key].concat(obj_to_kvp(opts.value));
return redis.hmset.apply(redis, args);


TRACE:09:29:10:Sending to Redis: hmset token:903acf5ac512481a921e9215b643a604 "id" "903acf5ac512481a921e9215b643a604" "value" "5hJPYT2rPSUnbfSms7bFuNgwCvo" "ttl" "86400" - lib/redis::bind
     lib/redis::bind
     lib/redis::bind
send redis-d001.liveclips.net:6379 id 1: *3
$5
hmset
$38
token:903acf5ac512481a921e9215b643a604
$91
"id" "903acf5ac512481a921e9215b643a604" "value" "5hJPYT2rPSUnbfSms7bFuNgwCvo" "ttl" "86400"

send_command buffered_writes: 0  should_buffer: false
net read redis-d001.liveclips.net:6379 id 1: -ERR wrong number of arguments for 'hmset' command

@nabeelio
Copy link

For some reason it didn't think of the arguments was a string, I had to iterate through the object and explicitly set each key and value to a string.

@Mikt25
Copy link

Mikt25 commented Jun 19, 2013

It seems only the first argument must be a string. The object with values could be numbers or strings.

redis.hmset("key", {"id": 5, somekey: "someval"}); //will work
redis.hmset(1, {"id": 5, somekey: "someval"}); //will not work

@ralexstokes
Copy link
Contributor

Added toString() conversion in client.hmset(key, object, [callback]) to fix this issue. HMSET function can now accept numbers (e.g. timestamps), although they are sent to Redis as strings. See code here: https://github.com/ralexstokes/node_redis/blob/master/index.js, beginning line 1036.

@aer123456
Copy link

你的某一个变量名或者函数的参数名与库发生冲突了,建议该参数名就好了。 我刚刚也遇到这个问题。

@BridgeAR
Copy link
Contributor

BridgeAR commented Mar 1, 2016

This is fixed in newer versions.

@tengwang0318
Copy link

你的某一个变量名或者函数的参数名与库发生冲突了,建议该参数名就好了。 我刚刚也遇到这个问题。

别说中文(don't speak Chinese in Github

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants