redis/redis-py · error · ValueError
Driver version must not be None
Error message
Driver version must not be None
What it means
Raised as ValueError by DriverInfo.add_upstream_driver (redis/driver_info.py:125) when driver_version is None. Like the name, a None version cannot be encoded into the LIB-VER portion of the CLIENT SETINFO payload, so it is rejected before formatting.
Source
Thrown at redis/driver_info.py:125
"""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
- Resolve a concrete version string before calling add_upstream_driver.
- Default to importlib.metadata.version('your-pkg') or a hardcoded fallback version.
- Fail loudly at startup if the version cannot be determined rather than passing None.
Example fix
// before
from importlib import metadata
info.add_upstream_driver('my-driver', metadata.version('my-driver') if pkg_found else None)
// after
from importlib import metadata
ver = metadata.version('my-driver') if pkg_found else '0.0.0'
info.add_upstream_driver('my-driver', ver) Defensive patterns
Strategy: validation
Validate before calling
from importlib import metadata
try:
version = metadata.version('my-driver')
except metadata.PackageNotFoundError:
version = '0.0.0'
info.add_upstream_driver(name, version) Type guard
def is_nonempty_str(v) -> bool:
return isinstance(v, str) and v != '' Prevention
- Resolve the version to a concrete string (importlib.metadata.version with a fallback) before passing it in.
- Fail at startup if the version is unknown rather than passing None.
- For CI-built packages, ensure the version is baked in, not read live from an unreliable source.
When it happens
Trigger: Calling add_upstream_driver(name, None) — e.g. a version read from package metadata or git that returned None, or a missing/optional version argument.
Common situations: importlib.metadata.version() failing under a fallback that yields None; a version derived from a git tag that was empty in CI; an optional version field whose default leaked through.
Related errors
- Driver name 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/602a06e2a83ee3b4.json.
Report an issue: GitHub.