Skip to content

redis.call doesn't throw lua error when passed nil arguments #651

Open
timbowhite opened this Issue Aug 29, 2012 · 3 comments

3 participants

@timbowhite

Hi, according to the EVAL docs, if "a Redis command call will result into an error, redis.call() will raise a Lua error". But check this out:

redis> eval "redis.call('llen', nil)" 0
(nil)

Command returned ok. But the redis.call did return a lua error:

redis> eval "local res = redis.call('llen', nil) return res" 0
(error) Lua redis() command arguments must be strings or integers

I suppose I was expecting something similar to this to happen:

redis> eval "redis.call('llen')" 0
(error) ERR Error running script (call to f_6fb575faf03c0feac7654c95d6dd9d9de1e75144): Wrong number of args calling Redis command From Lua script

This seems to happen with any command:

redis> eval "redis.call('hset', 'foo', 'bar', nil)" 0
(nil)

Server info:

redis> INFO
# Server
redis_version:2.5.12
redis_git_sha1:00000000
redis_git_dirty:0
os:Linux 2.6.35.11-83.fc14.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.5.1
process_id:17376
run_id:97410b61ad74e0a2819a93bd03762717567059c6
tcp_port:8666
uptime_in_seconds:173406
uptime_in_days:2
lru_clock:409082
@stevenh
stevenh commented Mar 14, 2016

This also occurs for booleans

eval "redis.call('HSET', 'mykey', 'field1', true); return true" 0
(integer) 1
eval "return redis.call('HSET', 'mykey', 'field1', true)" 0
(error) @user_script: 1: Lua redis() command arguments must be strings or integers
@badboy
badboy commented Mar 14, 2016

It seems to be fixed in 3.2 / unstable.

@stevenh
stevenh commented Mar 14, 2016

The commit which fixes this is: 1b5d24e

It would be nice if this could be pushed into the next 3.x release, as it would prevent much hair pulling 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.