redis/redis-py · error · DataError

XCLAIM retrycount must be an integer

Error message

XCLAIM retrycount must be an integer

What it means

Raised by xclaim() when the optional `retrycount` argument is provided but is not an int. Strict isinstance(int) at core.py:7313.

Source

Thrown at redis/commands/core.py:7314

                "XCLAIM message_ids must be a non empty list or "
                "tuple of message IDs to claim"
            )

        kwargs = {}
        pieces: list[EncodableT] = [name, groupname, consumername, str(min_idle_time)]
        pieces.extend(list(message_ids))

        if idle is not None:
            if not isinstance(idle, int):
                raise DataError("XCLAIM idle must be an integer")
            pieces.extend((b"IDLE", str(idle)))
        if time is not None:
            if not isinstance(time, int):
                raise DataError("XCLAIM time must be an integer")
            pieces.extend((b"TIME", str(time)))
        if retrycount is not None:
            if not isinstance(retrycount, int):
                raise DataError("XCLAIM retrycount must be an integer")
            pieces.extend((b"RETRYCOUNT", str(retrycount)))

        if force:
            if not isinstance(force, bool):
                raise DataError("XCLAIM force must be a boolean")
            pieces.append(b"FORCE")
        if justid:
            if not isinstance(justid, bool):
                raise DataError("XCLAIM justid must be a boolean")
            pieces.append(b"JUSTID")
            kwargs["parse_justid"] = True
        return self.execute_command("XCLAIM", *pieces, **kwargs)

    @overload
    def xdel(self: SyncClientProtocol, name: KeyT, *ids: StreamIdT) -> int: ...

    @overload
    def xdel(

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Pass an int, or None to omit.
  2. Coerce: retrycount = int(raw) if raw is not None else None.

Example fix

# before
r.xclaim('s','g','c', 0, ['1-0'], retrycount=msg['attempts'])  # str
# after
r.xclaim('s','g','c', 0, ['1-0'], retrycount=int(msg['attempts']))
Defensive patterns

Strategy: type-guard

Validate before calling

rc = int(retrycount) if retrycount is not None else None
r.xclaim(name, group, consumer, ms, ids, retrycount=rc)

Type guard

def opt_int(v): return v if v is None else int(v)

Try / catch

from redis.exceptions import DataError
try:
    r.xclaim(name, group, consumer, ms, ids, retrycount=rc)
except DataError:
    r.xclaim(name, group, consumer, ms, ids, retrycount=int(rc))

Prevention

When it happens

Trigger: xclaim(..., retrycount='3') (str), =3.0 (float). retrycount=None or omitted is valid.

Common situations: Passing a delivery-count from a dict/JSON as a string; a float average.

Related errors


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