redis/redis-py · error · DataError

CLIENT KILL skipme must be a bool

Error message

CLIENT KILL skipme must be a bool

What it means

Raised by client_kill when the skipme argument is not a Python bool. redis-py uses isinstance(skipme, bool) to enforce this because the argument is encoded as the literal bytes b'YES' or b'NO' — any non-boolean truthiness would be ambiguous.

Source

Thrown at redis/commands/core.py:782

        :param _type: Kills a client by type where type is one of 'normal',
        'master', 'slave', 'replica' or 'pubsub'
        :param addr: Kills a client by its 'address:port'
        :param skipme: If True, then the client calling the command
        will not get killed even if it is identified by one of the filter
        options. If skipme is not provided, the server defaults to skipme=True
        :param laddr: Kills a client by its 'local (bind) address:port'
        :param user: Kills a client for a specific user name
        :param maxage: Kills clients that are older than the specified age in seconds
        """
        args = []
        if _type is not None:
            client_types = ("normal", "master", "slave", "replica", "pubsub")
            if str(_type).lower() not in client_types:
                raise DataError(f"CLIENT KILL type must be one of {client_types!r}")
            args.extend((b"TYPE", _type))
        if skipme is not None:
            if not isinstance(skipme, bool):
                raise DataError("CLIENT KILL skipme must be a bool")
            if skipme:
                args.extend((b"SKIPME", b"YES"))
            else:
                args.extend((b"SKIPME", b"NO"))
        if _id is not None:
            args.extend((b"ID", _id))
        if addr is not None:
            args.extend((b"ADDR", addr))
        if laddr is not None:
            args.extend((b"LADDR", laddr))
        if user is not None:
            args.extend((b"USER", user))
        if maxage is not None:
            args.extend((b"MAXAGE", maxage))
        if not args:
            raise DataError(
                "CLIENT KILL <filter> <value> ... ... <filter> "
                "<value> must specify at least one filter"

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Pass skipme as a Python bool: skipme=True or skipme=False.
  2. If the value comes from config/env as a string, convert it: skipme=str_to_bool(config_val).
  3. Leave skipme unset (default None) to let the Redis server default to skipme=True.

Example fix

# before
r.client_kill(addr='10.0.0.1:6379', skipme='yes')
# after
r.client_kill(addr='10.0.0.1:6379', skipme=True)
Defensive patterns

Strategy: type-guard

Validate before calling

if skipme is not None and not isinstance(skipme, bool):
    skipme = str(skipme).lower() in ('true', 'yes', '1')
# now safe to pass

Type guard

def is_skipme_bool(v) -> bool:
    return v is None or isinstance(v, bool)

Prevention

When it happens

Trigger: Calling r.client_kill(skipme='yes'), r.client_kill(skipme=1), r.client_kill(skipme='true'), or r.client_kill(skipme=None) after passing None explicitly. Passing an int (1/0) or string instead of True/False.

Common situations: Developer reads 'skipme' in docs and passes a string 'yes'/'no'. Passing 1 or 0 (int) thinking Python will coerce it. Loading skipme from a config file or env var that yields a string.

Related errors


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