{"record":{"id":"3c1303db54e9934a","repo":"redis/redis-py","slug":"client-list-type-must-be-one-of-client-types-r","errorCode":null,"errorMessage":"CLIENT LIST _type must be one of {client_types!r}","messagePattern":"CLIENT LIST _type must be one of (.+?)","errorType":"exception","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":856,"sourceCode":"\n    def client_list(\n        self, _type: str | None = None, client_id: List[EncodableT] = [], **kwargs\n    ) -> list[dict[str, str]] | Awaitable[list[dict[str, str]]]:\n        \"\"\"\n        Returns a list of currently connected clients.\n        If type of client specified, only that type will be returned.\n\n        :param _type: optional. one of the client types (normal, master,\n         replica, pubsub)\n        :param client_id: optional. a list of client ids\n\n        For more information, see https://redis.io/commands/client-list\n        \"\"\"\n        args = []\n        if _type is not None:\n            client_types = (\"normal\", \"master\", \"replica\", \"pubsub\")\n            if str(_type).lower() not in client_types:\n                raise DataError(f\"CLIENT LIST _type must be one of {client_types!r}\")\n            args.append(b\"TYPE\")\n            args.append(_type)\n        if not isinstance(client_id, list):\n            raise DataError(\"client_id must be a list\")\n        if client_id:\n            args.append(b\"ID\")\n            args += client_id\n        return self.execute_command(\"CLIENT LIST\", *args, **kwargs)\n\n    @overload\n    def client_getname(self: SyncClientProtocol, **kwargs) -> bytes | str | None: ...\n\n    @overload\n    def client_getname(\n        self: AsyncClientProtocol, **kwargs\n    ) -> Awaitable[bytes | str | None]: ...\n\n    def client_getname(self, **kwargs) -> (bytes | str | None) | Awaitable[","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L838-L874","documentation":"Raised by client_list() (redis/commands/core.py:856) when _type is not one of ('normal','master','replica','pubsub'). The check is case-insensitive via str(_type).lower(), so 'Normal' or 'REPLICA' pass. Note this set is SMALLER than client_kill's type set: client_list does NOT accept 'slave' (use 'replica'). This is a redis.exceptions.DataError raised before the command is sent.","triggerScenarios":"Calling r.client_list(_type=\"slave\") (legacy spelling not allowed here), r.client_list(_type=\"clients\"), r.client_list(_type=\"all\"), or any unrecognized string. _type=None (default) is fine.","commonSituations":"Reusing the 'slave' spelling that works elsewhere in Redis, or inventing a type name like 'all'/'clients'. Also when copy-pasting from client_kill examples that include 'slave'.","solutions":["Use one of the accepted values: r.client_list(_type=\"normal\"), _type=\"master\", _type=\"replica\", or _type=\"pubsub\"","Replace legacy 'slave' with 'replica' for client_list","Drop the _type argument to list every connected client regardless of type"],"exampleFix":"# before\nr.client_list(_type=\"slave\")\n# after\nr.client_list(_type=\"replica\")","handlingStrategy":"validation","validationCode":"CLIENT_LIST_TYPES = {\"normal\", \"master\", \"replica\", \"pubsub\"}\nif _type is not None and _type.lower() not in CLIENT_LIST_TYPES:\n    raise ValueError(f\"_type must be one of {CLIENT_LIST_TYPES}\")\nr.client_list(_type=_type)","typeGuard":"from typing import Literal\nClientListType = Literal[\"normal\", \"master\", \"replica\", \"pubsub\"]\ndef is_client_list_type(v: str) -> TypeGuard[ClientListType]:\n    return v.lower() in {\"normal\", \"master\", \"replica\", \"pubsub\"}","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    r.client_list(_type=t)\nexcept DataError as e:\n    if \"_type must be one of\" in str(e):\n        r.client_list()  # fall back to unfiltered list\n    else:\n        raise","preventionTips":["Remember client_list does NOT accept 'slave'; use 'replica'.","Normalize _type to lowercase before calling (the check is case-insensitive).","Keep an allowlist constant near your call site rather than hardcoding strings."],"tags":["client-management","validation","dataerror","redis-version-compat"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}