mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
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
This commit is contained in:
parent
4de1031d8a
commit
4c14e8668c
@ -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) {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user