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() (redis/commands/core.py:782) when the 'skipme' argument is not a Python bool. The library must emit the literal wire tokens b"YES"/b"NO", so it enforces isinstance(skipme, bool) strictly; truthy/falsy values like the string "YES", the int 1, or "true" are rejected. skipme=None is allowed and simply omits the filter. This is a redis.exceptions.DataError raised client-side before any network round trip.

Solutions

  1. Pass a literal Python bool: r.client_kill(skipme=True) or r.client_kill(skipme=False)
  2. Omit skipme entirely (default None) if you do not need to control self-exclusion
  3. If skipme comes from config, coerce explicitly: r.client_kill(skipme=bool(user_value))

Example fix

# before
r.client_kill(skipme="YES")
# after
r.client_kill(skipme=True)
Defensive patterns

Strategy: validation

Validate before calling

if skipme is not None and not isinstance(skipme, bool):
    raise TypeError("skipme must be bool or None")
r.client_kill(skipme=skipme)

Type guard

def is_skipme(v) -> TypeGuard[bool]:
    return isinstance(v, bool)

Try / catch

from redis.exceptions import DataError
try:
    r.client_kill(skipme=val)
except DataError as e:
    if "skipme must be a bool" in str(e):
        r.client_kill(skipme=bool(val))
    else:
        raise

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=0). Any non-bool, non-None value triggers it. The default skipme=None does NOT trigger it.

Common situations: Developers copy the literal SKIPME YES/NO tokens from the Redis CLI/server docs and pass them as strings; or they assume Python truthiness (0/1) is accepted. Common when porting raw command examples into the python client.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/f7d0859815fd01a9. Report an issue: GitHub.

Appendix: 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 6a6b581b48)