Describe the bug

XREADGROUP can output a misleading error message regarding use of the $ special ID.

To reproduce

Redis 7:

127.0.0.1:6379> xreadgroup group workers worker1 count 1 streams mystream
(error) ERR Unbalanced XREAD list of streams: for each stream key an ID or '$' must be specified.
127.0.0.1:6379> xreadgroup group workers worker1 count 1 streams mystream $
(error) ERR The $ ID is meaningless in the context of XREADGROUP: you want to read the history of this consumer by specifying a proper ID, or use the > ID to get new messages. The $ ID would just return an empty result set.
127.0.0.1:6379> xreadgroup group workers worker1 count 1 streams mystream >
1) 1) "mystream"
   2) 1) 1) "1673544607848-0"
         2) 1) "n"
            2) "1"

Note that XREADGROUP first returns an error with the following problems in it:

  • Command name in the error should be XREADGROUP not XREAD.
  • It recommends using $ as an option for a stream ID... then when you try this (see second XREADGROUP command above) it errors telling you that $ doesn't make sense in this context even though the previous error message told you to use it.
  • Suggest that the command name be fixed in the first message, and the second error message be amended not to talk about using $ but > instead - this works, see the third and final XREADGROUP example above.

Expected behavior

A description of what you expected to happen.

Additional information

Any additional information that is relevant to the problem.

Comment From: itamarhaber

Thanks @simonprickett - I agree this is "somewhat" misleading. Would you care to submit a fix, or is #help-wanted?

Comment From: simonprickett

I'll try and fix it if you like - feel free to assign me!

Comment From: enjoy-binbin

@simonprickett Hi, are you working on it, or should i take over it if you are busy

i support a fix like this is enough:

diff --git a/src/t_stream.c b/src/t_stream.c
index 16ad044a2..262bba6c6 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -2205,9 +2205,9 @@ void xreadCommand(client *c) {
             streams_arg = i+1;
             streams_count = (c->argc-streams_arg);
             if ((streams_count % 2) != 0) {
-                addReplyError(c,"Unbalanced XREAD list of streams: "
-                                "for each stream key an ID or '$' must be "
-                                "specified.");
+                addReplyErrorFormat(c,"Unbalanced %s list of streams: "
+                                      "for each stream key an ID or '>' must be "
+                                      "specified.", (char *)c->argv[0]->ptr);
                 return;
             }
             streams_count /= 2; /* We have two arguments for each stream. */