redis/redis-py · error · DataError

XCLAIM justid must be a boolean

Error message

XCLAIM justid must be a boolean

What it means

Raised by xclaim() when `justid` is truthy but not a bool. Same shape as the force guard: it sits under `if justid:` (core.py:7321), so falsy non-bools slip through; truthy non-bools (1, 'yes') raise.

Source

Thrown at redis/commands/core.py:7323

            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(
        self: AsyncClientProtocol, name: KeyT, *ids: StreamIdT
    ) -> Awaitable[int]: ...

    def xdel(self, name: KeyT, *ids: StreamIdT) -> int | Awaitable[int]:
        """
        Deletes one or more messages from a stream.

        Args:
            name: name of the stream.

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Pass an actual bool: justid=bool(flag).
  2. Normalize string flags before the call.

Example fix

# before
r.xclaim('s','g','c', 0, ['1-0'], justid=req.args.get('justid'))  # '1'
# after
r.xclaim('s','g','c', 0, ['1-0'], justid=str(req.args.get('justid')).lower() in {'1','true','yes'})
Defensive patterns

Strategy: type-guard

Validate before calling

justid = bool(justid)
r.xclaim(name, group, consumer, ms, ids, justid=justid)

Type guard

def as_bool(v) -> bool:
    if isinstance(v, bool): return v
    if isinstance(v, str): return v.strip().lower() in {'1','true','yes','on'}
    return bool(v)

Try / catch

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

Prevention

When it happens

Trigger: xclaim(..., justid=1), =justid='true'), =justid='1'). justid=0/None does NOT raise. justid=True/False is correct.

Common situations: Passing justid from a query param or env flag as a string; an int 0/1.

Related errors


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