{"record":{"id":"e343dfd927e68ffb","repo":"redis/redis-py","slug":"xautoclaim-min-idle-time-must-be-a-nonnegative-int","errorCode":null,"errorMessage":"XAUTOCLAIM min_idle_time must be a nonnegative integer","messagePattern":"XAUTOCLAIM min_idle_time must be a nonnegative integer","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":7194,"sourceCode":"        criteria. Conceptually, equivalent to calling XPENDING and then XCLAIM,\n        but provides a more straightforward way to deal with message delivery\n        failures via SCAN-like semantics.\n        name: name of the stream.\n        groupname: name of the consumer group.\n        consumername: name of a consumer that claims the message.\n        min_idle_time: filter messages that were idle less than this amount of\n        milliseconds.\n        start_id: filter messages with equal or greater ID.\n        count: optional integer, upper limit of the number of entries that the\n        command attempts to claim. Set to 100 by default.\n        justid: optional boolean, false by default. Return just an array of IDs\n        of messages successfully claimed, without returning the actual message\n\n        For more information, see https://redis.io/commands/xautoclaim\n        \"\"\"\n        try:\n            if int(min_idle_time) < 0:\n                raise DataError(\n                    \"XAUTOCLAIM min_idle_time must be a nonnegative integer\"\n                )\n        except TypeError:\n            pass\n\n        kwargs = {}\n        pieces = [name, groupname, consumername, min_idle_time, start_id]\n\n        try:\n            if int(count) < 0:\n                raise DataError(\"XPENDING count must be a integer >= 0\")\n            pieces.extend([b\"COUNT\", count])\n        except TypeError:\n            pass\n        if justid:\n            pieces.append(b\"JUSTID\")\n            kwargs[\"parse_justid\"] = True\n","sourceCodeStart":7176,"sourceCodeEnd":7212,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L7176-L7212","documentation":"Raised by Redis.xautoclaim() when min_idle_time is coercible to int and the result is negative. Note the check is `int(min_idle_time) < 0` wrapped in try/except TypeError, so values that cannot be int()-converted are silently passed through to the server rather than rejected here. Only a negative coerced value triggers this DataError.","triggerScenarios":"Calling r.xautoclaim(name, group, consumer, min_idle_time=-1) or a string like '-5' (int('-5') == -5). A non-coercible value like 'abc' does NOT raise here (TypeError is swallowed) and is forwarded to the server.","commonSituations":"Sign error computing idle delta, or reusing a 'delay' variable that can go negative.","solutions":["Pass a non-negative integer for min_idle_time (milliseconds).","Guard the value: min_idle_time = max(0, int(min_idle_time)).","If the value may be a string, coerce and clamp before the call."],"exampleFix":"# before\nr.xautoclaim('s', 'g', 'c', min_idle_time=delta)  # delta = -1\n\n# after\nr.xautoclaim('s', 'g', 'c', min_idle_time=max(0, int(delta)))","handlingStrategy":"validation","validationCode":"if min_idle_time is not None and int(min_idle_time) < 0:\n    raise ValueError('min_idle_time must be >= 0')\nmin_idle_time = int(min_idle_time)","typeGuard":"lambda v: v is None or (isinstance(v, (int, str)) and int(v) >= 0)","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    r.xautoclaim('s','g','c', min_idle_time=t)\nexcept DataError as e:\n    log.warning('bad min_idle_time %r: %s', t, e)","preventionTips":["Coerce and clamp min_idle_time to >= 0 at the call site.","This guard only catches negatives; non-integer junk slips through to the server, so validate type yourself."],"tags":["stream","xautoclaim","validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}