[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: Oran Agra <oran@redislabs.com>
This commit is contained in:
Wen Hui 2023-05-28 01:37:32 -04:00 committed by GitHub
parent cb78acb865
commit 1a188e4ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -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. */

View File

@ -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