Unverified Commit 4c14e866 authored by Yang Bodong's avatar Yang Bodong Committed by GitHub
Browse files

Fix out of range confusing error messages (XAUTOCLAIM, RPOP count) (#8746)

Fix out of range error messages to be clearer (avoid mentioning 9223372036854775807)
* Fix XAUTOCLAIM COUNT option confusing error msg
* Fix other RPOP and alike error message to mention positive 
parent 4de1031d
......@@ -727,7 +727,11 @@ int getRangeLongFromObjectOrReply(client *c, robj *o, long min, long max, long *
}
int getPositiveLongFromObjectOrReply(client *c, robj *o, long *target, const char *msg) {
return getRangeLongFromObjectOrReply(c, o, 0, LONG_MAX, target, msg);
if (msg) {
return getRangeLongFromObjectOrReply(c, o, 0, LONG_MAX, target, msg);
} else {
return getRangeLongFromObjectOrReply(c, o, 0, LONG_MAX, target, "value is out of range, must be positive");
}
}
int getIntFromObjectOrReply(client *c, robj *o, int *target, const char *msg) {
......
......@@ -3051,12 +3051,8 @@ void xautoclaimCommand(client *c) {
int moreargs = (c->argc-1) - j; /* Number of additional arguments. */
char *opt = c->argv[j]->ptr;
if (!strcasecmp(opt,"COUNT") && moreargs) {
if (getPositiveLongFromObjectOrReply(c,c->argv[j+1],&count,NULL) != C_OK)
if (getRangeLongFromObjectOrReply(c,c->argv[j+1],1,LONG_MAX,&count,"COUNT must be > 0") != C_OK)
return;
if (count == 0) {
addReplyError(c,"COUNT must be > 0");
return;
}
j++;
} else if (!strcasecmp(opt,"JUSTID")) {
justid = 1;
......
......@@ -462,6 +462,10 @@ start_server {
assert_equal [lindex $reply 1 0 1] {e 5}
}
test {XAUTOCLAIM COUNT must be > 0} {
assert_error "ERR COUNT must be > 0" {r XAUTOCLAIM key group consumer 1 1 COUNT 0}
}
test {XINFO FULL output} {
r del x
r XADD x 100 a 1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment