redis/redis-py · error · DataError

if XPENDING is provided with idle time or consumername, it…

Error message

if XPENDING is provided with idle time or consumername, it must be provided with min, max and count parameters

What it means

Raised by Redis.xpending_range() when min, max, and count are all None but idle or consumername is provided. The range filters (min/max/count) are required whenever idle or consumername filters are used; without a range the filters are meaningless. The method then delegates to the simpler xpending() form only when no filters are set.

Solutions

  1. If you want the group summary (no range), drop idle and consumername and call r.xpending(name, group) directly.
  2. If you want a filtered range, supply min, max, and count together with the filter.

Example fix

# before
r.xpending_range('s','g', None, None, None, consumername='c')

# after -- summary form:
r.xpending('s','g')
# after -- filtered range form:
r.xpending_range('s','g', '-', '+', 10, consumername='c')
Defensive patterns

Strategy: validation

Validate before calling

if min is None and max is None and count is None:
    if idle is not None or consumername is not None:
        raise ValueError('idle/consumername require min,max,count')
    # use summary form

Type guard

None

Try / catch

from redis.exceptions import DataError
try:
    r.xpending_range('s','g', mn, mx, cnt, consumername=c)
except DataError as e:
    log.warning('xpending_range arg combination invalid: %s', e)

Prevention

When it happens

Trigger: Calling r.xpending_range('s','g', None, None, None, consumername='c') or with idle=1000 but min=max=count=None. Because min/max/count are positional, you must explicitly pass None to reach this state.

Common situations: Calling xpending_range intending a summary but passing a consumer filter, or partially filling arguments.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/6ae3997f779fcef2. Report an issue: GitHub.

Appendix: source

Thrown at redis/commands/core.py:7768

        count: int,
        consumername: ConsumerT | None = None,
        idle: int | None = None,
    ) -> XPendingRangeResponse | Awaitable[XPendingRangeResponse]:
        """
        Returns information about pending messages, in a range.

        name: name of the stream.
        groupname: name of the consumer group.
        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:

View on GitHub (pinned to 6a6b581b48)