According to the Redis documentation, the commands COMMAND-GETKEYS and COMMAND-GETKEYSANDFLAGS are helper commands that look for keys and flags in a command. However, for commands that do not have any keys, such as the COMMAND-INFO, which does not contain any keys, why does it respond with an error type?

in:

command getkeys command info
-ERR The command has no key arguments

My understanding of the function of this helper command is somewhat similar to finding the intersection of two arrays. If no results are found, it should respond with an empty or redis-nil (resp "_").

Just like the LCS command, if there are no results, it should respond with an empty string instead of an error type.

We have to rely on error strings to determine whether it's another type of error or a key not found error, and this causes a lot of trouble.

err = client.CommandGetKeys("command", "info").Error()
if err == "The command has no key arguments" {
      // no key, not error
}

Comment From: enjoy-binbin

that will be a breaking change @oranagra WDYT

Comment From: oranagra

i'm not sure about it. for some commands that can work with both keys and without (like EVAL), it does return an empty array. so maybe it is useful for the caller to be able to distinguish between that and commands that simply have nothing to do with keys. in any case, it's probably much better these days to use COMMAND INFO and work with key-specs rather than the extra round trip. and regardless, i don't think this odd choice of an error is a reason to change it by introducing a breaking change.