redis/redis-py · error · TypeError
driver_info must be a DriverInfo instance or None
Error message
driver_info must be a DriverInfo instance or None
What it means
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.
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.
Example fix
// before client = redis.Redis(driver_info='myapp') // after client = redis.Redis(driver_info=redis.driver_info.DriverInfo(name='myapp')) // or simply client = redis.Redis(lib_name='myapp')
Defensive patterns
Strategy: type-guard
Validate before calling
from redis.driver_info import DriverInfo
def coerce_driver_info(v):
if v is None or isinstance(v, DriverInfo):
return v
if isinstance(v, str):
return DriverInfo(name=v)
raise TypeError('driver_info must be DriverInfo or None') Type guard
from redis.driver_info import DriverInfo
def is_driver_info_or_none(v) -> bool:
return v is None or isinstance(v, DriverInfo) Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ACL LOG count must be an integer
- Driver name must not be None
- Driver version must not be None
- must not contain spaces, newlines, non-printable…
- Upstream driver name must use a Python package-style name…
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/2995aa591c3400a5.
Report an issue: GitHub.
Appendix: source
Thrown at redis/driver_info.py:184
lib_name : str, optional
The library name (default: "redis-py")
lib_version : str, optional
The library version (default: auto-detected)
Returns
-------
DriverInfo, optional
The resolved DriverInfo instance
"""
if driver_info is SENTINEL:
if lib_name is None and lib_version is None:
return None
return DriverInfo(name=lib_name, lib_version=lib_version)
if driver_info is None or isinstance(driver_info, DriverInfo):
return driver_info
raise TypeError("driver_info must be a DriverInfo instance or None")
View on GitHub (pinned to 6a6b581b48)