redis/redis-py · error · DataError
XCLAIM idle must be an integer
Error message
XCLAIM idle must be an integer
What it means
Raised by xclaim() when the optional `idle` argument is provided but is not an int. Strict isinstance(int) at core.py:7305; passing None is fine (omits the IDLE option).
Source
Thrown at redis/commands/core.py:7306
of messages successfully claimed, without returning the actual message
For more information, see https://redis.io/commands/xclaim
"""
if not isinstance(min_idle_time, int) or min_idle_time < 0:
raise DataError("XCLAIM min_idle_time must be a non negative integer")
if not isinstance(message_ids, (list, tuple)) or not message_ids:
raise DataError(
"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")View on GitHub (pinned to da03cdc7e8)
Solutions
- Pass an int milliseconds, or None to omit.
- Coerce: idle = int(raw) if raw is not None else None.
Example fix
# before
r.xclaim('s','g','c', 0, ['1-0'], idle='100')
# after
r.xclaim('s','g','c', 0, ['1-0'], idle=100) Defensive patterns
Strategy: type-guard
Validate before calling
idle = int(idle) if idle is not None else None r.xclaim(name, group, consumer, ms, ids, idle=idle)
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, idle=idle)
except DataError:
r.xclaim(name, group, consumer, ms, ids, idle=int(idle)) Prevention
- Coerce optional numeric kwargs with int() unless they are None.
When it happens
Trigger: xclaim(..., idle='100') (str), =100.0 (float). idle=None or omitted is valid.
Common situations: Passing a duration from config as a string; a float ms value; a Decimal.
Related errors
- XCLAIM min_idle_time must be a non negative integer
- XCLAIM time must be an integer
- XCLAIM retrycount must be an integer
- XCLAIM force must be a boolean
- XCLAIM justid must be a boolean
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/b19e3b4253374dde.json.
Report an issue: GitHub.