{"record":{"id":"01ea4439cd2150bc","repo":"redis/redis-py","slug":"client-kill-type-must-be-one-of-client-types-r","errorCode":null,"errorMessage":"CLIENT KILL type must be one of {client_types!r}","messagePattern":"CLIENT KILL type must be one of (.+?)","errorType":"exception","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":778,"sourceCode":"    ) -> int | Awaitable[int]:\n        \"\"\"\n        Disconnects client(s) using a variety of filter options\n        :param _id: Kills a client by its unique ID field\n        :param _type: Kills a client by type where type is one of 'normal',\n        'master', 'slave', 'replica' or 'pubsub'\n        :param addr: Kills a client by its 'address:port'\n        :param skipme: If True, then the client calling the command\n        will not get killed even if it is identified by one of the filter\n        options. If skipme is not provided, the server defaults to skipme=True\n        :param laddr: Kills a client by its 'local (bind) address:port'\n        :param user: Kills a client for a specific user name\n        :param maxage: Kills clients that are older than the specified age in seconds\n        \"\"\"\n        args = []\n        if _type is not None:\n            client_types = (\"normal\", \"master\", \"slave\", \"replica\", \"pubsub\")\n            if str(_type).lower() not in client_types:\n                raise DataError(f\"CLIENT KILL type must be one of {client_types!r}\")\n            args.extend((b\"TYPE\", _type))\n        if skipme is not None:\n            if not isinstance(skipme, bool):\n                raise DataError(\"CLIENT KILL skipme must be a bool\")\n            if skipme:\n                args.extend((b\"SKIPME\", b\"YES\"))\n            else:\n                args.extend((b\"SKIPME\", b\"NO\"))\n        if _id is not None:\n            args.extend((b\"ID\", _id))\n        if addr is not None:\n            args.extend((b\"ADDR\", addr))\n        if laddr is not None:\n            args.extend((b\"LADDR\", laddr))\n        if user is not None:\n            args.extend((b\"USER\", user))\n        if maxage is not None:\n            args.extend((b\"MAXAGE\", maxage))","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L760-L796","documentation":"Raised by Redis.client_kill() when the `_type` argument is supplied but is not one of the allowed client types: 'normal', 'master', 'slave', 'replica', 'pubsub' (case-insensitive via str(_type).lower()). The library validates before building the CLIENT KILL argument list. Other filter fields (_id, addr, laddr, user, maxage, skipme) are not subject to this specific check.","triggerScenarios":"Calling client.client_kill(_type='publisher') (invalid), _type='PUBSUB' (valid, case-insensitive), _type='slave' (valid), or _type='replica' (valid). A misspelled or unsupported type like 'pub' or 'subscriber' triggers the error.","commonSituations":"Mismatched terminology between your app ('publisher','subscriber') and Redis client types; passing a numeric type code instead of the string name; case-sensitivity assumptions (the check lowercases, so casing is fine, but spelling must match).","solutions":["Use one of 'normal', 'master', 'slave', 'replica', 'pubsub' for _type.","Prefer 'replica' over 'slave' for forward compatibility (both are accepted).","If you have a custom enum, map it to these canonical names before calling."],"exampleFix":"# before\nclient.client_kill(_type='subscriber')\n# after\nclient.client_kill(_type='pubsub')","handlingStrategy":"validation","validationCode":"VALID_CLIENT_KILL_TYPES = {'normal', 'master', 'slave', 'replica', 'pubsub'}\ndef safe_client_kill(client, _type=None, **kw):\n    if _type is not None and str(_type).lower() not in VALID_CLIENT_KILL_TYPES:\n        raise ValueError(f'_type must be one of {VALID_CLIENT_KILL_TYPES}, got {_type!r}')\n    return client.client_kill(_type=_type, **kw)","typeGuard":"def is_valid_client_kill_type(_type) -> bool:\n    return _type is None or (isinstance(_type, str) and _type.lower() in {'normal', 'master', 'slave', 'replica', 'pubsub'})","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.client_kill(_type=_type)\nexcept DataError as e:\n    if 'CLIENT KILL type' in str(e):\n        # map or reject upstream; do not blindly retry\n        raise ValueError(f'invalid client kill type: {_type}') from e\n    raise","preventionTips":["Map your application's client-type enum to Redis's canonical names before calling.","Prefer 'replica' over 'slave' for forward compatibility.","Centralize CLIENT KILL usage behind a validated helper."],"tags":["client","validation","client-kill","input-validation","enum"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}