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
        # consumername

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Provide all three: min, max, AND count.
  2. Use '+' for max and '-' for min when you want the full pending range.
  3. 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

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


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/91bb10bd32513af5.json. Report an issue: GitHub.