redis/redis-py · error · DataError
XPENDING must be provided with min, max and count parameters
Error message
XPENDING must be provided with min, max and count parameters, or none of them.
What it means
Raised by xpending_range() when min, max, count are PARTIALLY provided (some None, some not). They must be all-present or all-absent together. Check at core.py:7776: `if min is None or max is None or count is None`. This branch is only reached after the all-None case ([337] path) was excluded.
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 da03cdc7e8)
Solutions
- Provide all three: min, max, AND count.
- Use '+' for max and '-' for min when you want the full pending range.
- If you only want the summary, pass all three as None and drop idle/consumername.
Example fix
# before
r.xpending_range('s','g','0-0', None, 10) # max is None
# after
r.xpending_range('s','g','0-0', '+', 10) Defensive patterns
Strategy: validation
Validate before calling
if (min is None) != (max is None) or (min is None) != (count is None):
raise ValueError('min, max, count must be all set or all None')
if min is None:
r.xpending(name, group)
else:
r.xpending_range(name, group, min, max, count) Try / catch
from redis.exceptions import DataError
try:
r.xpending_range(name, group, min, max, count)
except DataError:
# fill in sensible defaults for the missing one
r.xpending_range(name, group, min or '-', max or '+', count or 10) Prevention
- min/max/count are atomic - supply all three or none.
- '-' / '+' are the conventional min/max stream-id bounds.
When it happens
Trigger: r.xpending_range('s','g','0-0', None, 10) (max missing), =('s','g', None, '+', 10) (min missing), r.xpending_range('s','g','0-0','+',None) (count missing).
Common situations: Mixing keyword and positional args and leaving one as its required-but-None slot; forgetting one of the three; passing count from a config that was unset.
Related errors
- if XPENDING is provided with idle time or consumername, it m
- XPENDING idle must be a integer >= 0
- XCFGSET requires at least one of idmp_duration or idmp_maxsi
- XCFGSET idmp_duration must be an integer between 1 and 300
- XCFGSET idmp_maxsize must be an integer between 1 and 1,000,
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/91bb10bd32513af5.json.
Report an issue: GitHub.