{"record":{"id":"2995aa591c3400a5","repo":"redis/redis-py","slug":"driver-info-must-be-a-driverinfo-instance-or-none","errorCode":null,"errorMessage":"driver_info must be a DriverInfo instance or None","messagePattern":"driver_info must be a DriverInfo instance or None","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"redis/driver_info.py","lineNumber":184,"sourceCode":"    lib_name : str, optional\n        The library name (default: \"redis-py\")\n    lib_version : str, optional\n        The library version (default: auto-detected)\n\n    Returns\n    -------\n    DriverInfo, optional\n        The resolved DriverInfo instance\n    \"\"\"\n    if driver_info is SENTINEL:\n        if lib_name is None and lib_version is None:\n            return None\n        return DriverInfo(name=lib_name, lib_version=lib_version)\n\n    if driver_info is None or isinstance(driver_info, DriverInfo):\n        return driver_info\n\n    raise TypeError(\"driver_info must be a DriverInfo instance or None\")\n","sourceCodeStart":166,"sourceCodeEnd":185,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/driver_info.py#L166-L185","documentation":"resolve_driver_info (redis/driver_info.py:184) is the single funnel that reconciles the new driver_info parameter with the legacy lib_name/lib_version parameters. If driver_info is provided but is neither None nor a DriverInfo instance, it raises TypeError, because passing a string/dict/other object there is a programming error rather than a valid configuration.","triggerScenarios":"Calling Redis(..., driver_info='redis-py') or driver_info={'name': 'x'} (passing a string or dict where a DriverInfo or None is required); passing an old-style lib_name accidentally as driver_info.","commonSituations":"Migrating from the lib_name=/lib_version= kwargs to the driver_info= kwarg and passing the old string value into the new slot; a wrapper library forwarding **kwargs that maps the wrong key.","solutions":["Pass either a DriverInfo instance or None (or omit driver_info and use lib_name/lib_version).","If you only have a name/version, construct DriverInfo(name=..., lib_version=...) first, or just use the lib_name=/lib_version= kwargs which resolve_driver_info accepts.","Add a type check in your wrapper so a stray string is converted to DriverInfo before being forwarded."],"exampleFix":"// before\nclient = redis.Redis(driver_info='myapp')\n// after\nclient = redis.Redis(driver_info=redis.driver_info.DriverInfo(name='myapp'))\n// or simply\nclient = redis.Redis(lib_name='myapp')","handlingStrategy":"type-guard","validationCode":"from redis.driver_info import DriverInfo\ndef coerce_driver_info(v):\n    if v is None or isinstance(v, DriverInfo):\n        return v\n    if isinstance(v, str):\n        return DriverInfo(name=v)\n    raise TypeError('driver_info must be DriverInfo or None')","typeGuard":"from redis.driver_info import DriverInfo\ndef is_driver_info_or_none(v) -> bool:\n    return v is None or isinstance(v, DriverInfo)","tryCatchPattern":null,"preventionTips":["Pass a DriverInfo instance or None, or use the legacy lib_name=/lib_version= kwargs.","In wrapper libraries, type-check and coerce stray strings to DriverInfo before forwarding.","Do not forward arbitrary **kwargs into driver_info without validation."],"tags":["driver-info","type-check","validation","client-config"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}