redis/redis-py · error · RedisClusterException

Invalid args in command: {args}

Error message

Invalid args in command: {args}

What it means

Error "Invalid args in command: {args}" thrown in redis/redis-py.

Source

Thrown at redis/cluster.py:1465

            # The command contains the slot ID
            return args[1]

        # Get the keys in the command

        # CLIENT TRACKING is a special case.
        # It doesn't have any keys, it needs to be sent to the provided nodes
        # By default it will be sent to all nodes.
        if command.upper() == "CLIENT TRACKING":
            return None

        # EVAL and EVALSHA are common enough that it's wasteful to go to the
        # redis server to parse the keys. Besides, there is a bug in redis<7.0
        # where `self._get_command_keys()` fails anyway. So, we special case
        # EVAL/EVALSHA.
        if command.upper() in ("EVAL", "EVALSHA"):
            # command syntax: EVAL "script body" num_keys ...
            if len(args) <= 2:
                raise RedisClusterException(f"Invalid args in command: {args}")
            num_actual_keys = int(args[2])
            eval_keys = args[3 : 3 + num_actual_keys]
            # if there are 0 keys, that means the script can be run on any node
            # so we can just return a random slot
            if len(eval_keys) == 0:
                return random.randrange(0, REDIS_CLUSTER_HASH_SLOTS)
            keys = eval_keys
        else:
            keys = self._get_command_keys(*args)
            if keys is None or len(keys) == 0:
                # FCALL can call a function with 0 keys, that means the function
                #  can be run on any node so we can just return a random slot
                if command.upper() in ("FCALL", "FCALL_RO"):
                    return random.randrange(0, REDIS_CLUSTER_HASH_SLOTS)
                raise RedisClusterException(
                    "No way to dispatch this command to Redis Cluster. "
                    "Missing key.\nYou can execute the command by specifying "
                    f"target nodes.\nCommand: {args}"

View on GitHub (pinned to da03cdc7e8)

When it happens

Trigger: Thrown at redis/cluster.py:1465 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/7f1e8b72f40bb827.json. Report an issue: GitHub.