redis/redis-py · error · ValueError
Upstream driver name must use a Python package-style name: s
Error message
Upstream driver name must use a Python package-style name: start with a lowercase letter and contain only lowercase letters, digits, hyphens, and underscores (e.g., 'django-redis').
What it means
Raised as ValueError by _validate_driver_name (redis/driver_info.py:42). Beyond the character check, an upstream driver name must match ^[a-z][a-z0-9_-]*$ — start with a lowercase letter and contain only lowercase letters, digits, hyphens, underscores — following a simplified PEP 503 normalization so it is a valid Python-distribution-style identifier (e.g. 'django-redis').
Source
Thrown at redis/driver_info.py:42
def _validate_driver_name(name: str) -> None:
"""Validate an upstream driver name.
The name should look like a typical Python distribution or package name,
following a simplified form of PEP 503 normalisation rules:
* start with a lowercase ASCII letter
* contain only lowercase letters, digits, hyphens and underscores
Examples of valid names: ``"django-redis"``, ``"celery"``, ``"rq"``.
"""
import re
_validate_no_invalid_chars(name, "Driver name")
if not re.match(r"^[a-z][a-z0-9_-]*$", name):
raise ValueError(
"Upstream driver name must use a Python package-style name: "
"start with a lowercase letter and contain only lowercase letters, "
"digits, hyphens, and underscores (e.g., 'django-redis')."
)
def _validate_driver_version(version: str) -> None:
_validate_no_invalid_chars(version, "Driver version")
def _format_driver_entry(driver_name: str, driver_version: str) -> str:
return f"{driver_name}_v{driver_version}"
@dataclass
class DriverInfo:
"""Driver information used to build the CLIENT SETINFO LIB-NAME and LIB-VER values.
View on GitHub (pinned to da03cdc7e8)
Solutions
- Normalize the name to lowercase ASCII with hyphens/underscores, starting with a letter: e.g. 'django-redis'.
- Move any version into the version argument, not the name.
- Lowercase and replace disallowed separators before passing: name.lower().replace('.','-').
Example fix
// before
info.add_upstream_driver('Django.Redis', '5.4.0')
// after
info.add_upstream_driver('django-redis', '5.4.0') Defensive patterns
Strategy: validation
Validate before calling
import re
_NAME = re.compile(r'^[a-z][a-z0-9_-]*$')
def normalize_driver_name(name: str) -> str:
n = name.strip().lower().replace('.', '-').replace(' ', '-')
if not _NAME.match(n):
raise ValueError(f'invalid driver name: {name!r}')
return n
info.add_upstream_driver(normalize_driver_name(name), version) Type guard
import re
_DRIVER_NAME = re.compile(r'^[a-z][a-z0-9_-]*$')
def is_valid_driver_name(name) -> bool:
return isinstance(name, str) and bool(_DRIVER_NAME.match(name)) Prevention
- Keep the name lowercase, letter-first, hyphen/underscore/digit only — think PyPI distribution name.
- Put the version in the version argument, not the name.
- Normalize names at the boundary: .lower().replace('.', '-') before validation.
- Avoid uppercase letters, dots, slashes, and leading digits in driver names.
When it happens
Trigger: Calling DriverInfo().add_upstream_driver(name, ...) with a name starting with a digit, containing an uppercase letter, a dot, a slash, or any character outside [a-z0-9_-].
Common situations: Passing a package import path (e.g. 'django_redis' is fine, but 'Django.Redis' is not); a name starting with a digit; using the distribution title with a capital letter; embedding a version or path separator in the name.
Related errors
- {field_name} must not contain spaces, newlines, non-printabl
- Driver name must not be None
- Driver version must not be None
- 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/6996914d6bc10042.json.
Report an issue: GitHub.