{"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":"validation","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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/core.py#L760-L796","documentation":"Raised by client_kill when the _type argument is not one of the five recognized client types: ('normal', 'master', 'slave', 'replica', 'pubsub'). The check is case-insensitive via str(_type).lower(), so casing is tolerated but the value must match exactly one of those strings. redis-py validates this client-side before sending anything to the server.","triggerScenarios":"Calling r.client_kill(_type='worker'), r.client_kill(_type='subscriber'), or any _type value outside the five allowed strings. Passing an integer or object as _type whose str().lower() form isn't in the tuple also triggers it.","commonSituations":"Developer confuses Redis pub/sub subscriber terminology ('subscriber') with the actual type name ('pubsub'). Copy-pasting a _type value from documentation that uses a synonym. Typing 'replicas' (plural) instead of 'replica'.","solutions":["Use one of the exact allowed values: 'normal', 'master', 'slave', 'replica', or 'pubsub' (case-insensitive).","If targeting a pub/sub subscriber connection, use _type='pubsub' not 'subscriber'.","If you need to kill a specific connection instead of by type, use _id, addr, laddr, user, or maxage parameters."],"exampleFix":"# before\nr.client_kill(_type='subscriber')\n# after\nr.client_kill(_type='pubsub')","handlingStrategy":"validation","validationCode":"VALID_KILL_TYPES = {'normal', 'master', 'slave', 'replica', 'pubsub'}\nif _type is not None and str(_type).lower() not in VALID_KILL_TYPES:\n    raise ValueError(f'Invalid client kill type: {_type}')","typeGuard":"def is_valid_kill_type(t: str) -> bool:\n    return isinstance(t, str) and t.lower() in {'normal', 'master', 'slave', 'replica', 'pubsub'}","tryCatchPattern":null,"preventionTips":["Centralize allowed client-type strings in a shared constant referenced at call sites.","Note that 'subscriber' is not valid; Redis uses 'pubsub'."],"tags":["client-management","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}