Unverified Commit 1a188e4e authored by Wen Hui's avatar Wen Hui Committed by GitHub
Browse files

[BUG] Incorrect error msg for XREAD command (#12238)



XREAD only supports a special ID of $ and XREADGROUP only supports ^.
make sure not to suggest the wrong one when rerunning an error about unbalanced ID arguments
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
parent cb78acb8
......@@ -2208,9 +2208,10 @@ void xreadCommand(client *c) {
streams_arg = i+1;
streams_count = (c->argc-streams_arg);
if ((streams_count % 2) != 0) {
char symbol = xreadgroup ? '>' : '$';
addReplyErrorFormat(c,"Unbalanced '%s' list of streams: "
"for each stream key an ID or '>' must be "
"specified.", c->cmd->fullname);
"for each stream key an ID or '%c' must be "
"specified.", c->cmd->fullname,symbol);
return;
}
streams_count /= 2; /* We have two arguments for each stream. */
......
......@@ -314,6 +314,14 @@ start_server {
$rd close
} {0} {external:skip}
test {XREAD and XREADGROUP against wrong parameter} {
r DEL mystream
r XADD mystream 666 f v
r XGROUP CREATE mystream mygroup $
assert_error "ERR Unbalanced 'xreadgroup' list of streams: for each stream key an ID or '>' must be specified." {r XREADGROUP GROUP mygroup Alice COUNT 1 STREAMS mystream }
assert_error "ERR Unbalanced 'xread' list of streams: for each stream key an ID or '$' must be specified." {r XREAD COUNT 1 STREAMS mystream }
}
test {Blocking XREAD: key deleted} {
r DEL mystream
r XADD mystream 666 f v
......
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