redis/redis-py · error · ValueError
Driver name must not be None
Error message
Driver name must not be None
What it means
Raised as ValueError by DriverInfo.add_upstream_driver (redis/driver_info.py:123) when driver_name is None. A None name cannot be formatted into the CLIENT SETINFO LIB-NAME payload, so it is rejected explicitly before any further validation runs.
Source
Thrown at redis/driver_info.py:123
@property
def upstream_drivers(self) -> List[str]:
"""Return a copy of the upstream driver entries.
Each entry is in the form ``"driver-name_vversion"``.
"""
return list(self._upstream)
def add_upstream_driver(
self, driver_name: str, driver_version: str
) -> "DriverInfo":
"""Add an upstream driver to this instance and return self.
The most recently added driver appears first in :pyattr:`formatted_name`.
"""
if driver_name is None:
raise ValueError("Driver name must not be None")
if driver_version is None:
raise ValueError("Driver version must not be None")
_validate_driver_name(driver_name)
_validate_driver_version(driver_version)
entry = _format_driver_entry(driver_name, driver_version)
# insert at the beginning so latest is first
self._upstream.insert(0, entry)
return self
@property
def formatted_name(self) -> Optional[str]:
"""Return the base name with upstream drivers encoded, if any.
With no upstream drivers, this is just :pyattr:`name`. Otherwise::
name(driver1_vX;driver2_vY)View on GitHub (pinned to da03cdc7e8)
Solutions
- Ensure the name is a non-None string before calling add_upstream_driver.
- Default the name to a real identifier (your package's __title__) when the source is optional.
- Validate config at load time so None never reaches the DriverInfo API.
Example fix
// before
info.add_upstream_driver(os.environ.get('DRIVER_NAME'), '1.0.0') # None if unset
// after
info.add_upstream_driver(os.environ.get('DRIVER_NAME') or 'my-driver', '1.0.0') Defensive patterns
Strategy: validation
Validate before calling
name = os.environ.get('DRIVER_NAME') or 'my-driver'
assert name is not None, 'driver name missing'
info.add_upstream_driver(name, version) Type guard
def is_nonempty_str(v) -> bool:
return isinstance(v, str) and v != '' Prevention
- Default optional name fields to a concrete identifier rather than None.
- Validate config-derived names at startup and fail loudly if missing.
- Never pass an unvalidated os.environ.get(...) result straight into add_upstream_driver.
When it happens
Trigger: Calling add_upstream_driver(None, version) — typically because a variable holding the name was uninitialized, came back None from a config lookup, or a default argument leaked through.
Common situations: Reading driver metadata from an env var / config that returned None; an optional field whose default propagated; a refactor that dropped the name argument.
Related errors
- Driver version must not be None
- {field_name} must not contain spaces, newlines, non-printabl
- Upstream driver name must use a Python package-style name: s
- Cannot use FIELDNAME alias with no field
- Bad query type {type(query)}
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/9aac042e86bda15a.json.
Report an issue: GitHub.