redis/redis-py · error · DataError
XPENDING must be provided with min, max and count…
Error message
XPENDING must be provided with min, max and count parameters, or none of them.
What it means
Raised by Redis.xpending_range() when some but not all of min/max/count are None. They must be supplied together (all three) or all omitted. The first branch handles all-None; this branch catches the partial case.
Solutions
- Supply min, max, and count together, or omit all three (use xpending for summary).
- Build them as a tuple and pass atomically: if any is None, treat as summary.
Example fix
# before
r.xpending_range('s','g', '0-0', None, 10) # max missing -> raises
# after
r.xpending_range('s','g', '0-0', '+', 10) Defensive patterns
Strategy: validation
Validate before calling
if (min is None) ^ (max is None) ^ (count is None) or (min is None and (max is not None or count is not None)):
raise ValueError('min, max, count must be supplied together or all omitted') Type guard
None
Try / catch
from redis.exceptions import DataError
try:
r.xpending_range('s','g', mn, mx, cnt)
except DataError as e:
log.warning('xpending_range needs all or none of min/max/count: %s', e) Prevention
- Treat (min, max, count) as a single optional triple in your calling code.
When it happens
Trigger: Calling r.xpending_range('s','g', '0-0', None, 10) (max missing) or r.xpending_range('s','g', None, '+', 10) (min missing).
Common situations: Forgetting one of the three positional args, or conditionally building only some of them.
Related errors
- if XPENDING is provided with idle time or consumername, it…
- XPENDING idle must be a integer >= 0
- XAUTOCLAIM min_idle_time must be a nonnegative integer
- XCFGSET idmp_duration must be an integer between 1 and 300
- XCFGSET idmp_maxsize must be an integer between 1 and…
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/91bb10bd32513af5.
Report an issue: GitHub.
Appendix: source
Thrown at redis/commands/core.py:7777
idle: available from version 6.2. filter entries by their
idle-time, given in milliseconds (optional).
min: minimum stream ID.
max: maximum stream ID.
count: number of messages to return
consumername: name of a consumer to filter by (optional).
"""
if {min, max, count} == {None}:
if idle is not None or consumername is not None:
raise DataError(
"if XPENDING is provided with idle time"
" or consumername, it must be provided"
" with min, max and count parameters"
)
return self.xpending(name, groupname)
pieces = [name, groupname]
if min is None or max is None or count is None:
raise DataError(
"XPENDING must be provided with min, max "
"and count parameters, or none of them."
)
# idle
try:
if int(idle) < 0:
raise DataError("XPENDING idle must be a integer >= 0")
pieces.extend(["IDLE", idle])
except TypeError:
pass
# count
try:
if int(count) < 0:
raise DataError("XPENDING count must be a integer >= 0")
pieces.extend([min, max, count])
except TypeError:
pass
# consumernameView on GitHub (pinned to 6a6b581b48)