{"record":{"id":"3f5f2e7f5aa9db33","repo":"redis/redis-py","slug":"xclaim-min-idle-time-must-be-a-non-negative-intege","errorCode":null,"errorMessage":"XCLAIM min_idle_time must be a non negative integer","messagePattern":"XCLAIM min_idle_time must be a non negative integer","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":7293,"sourceCode":"        time: optional integer. This is the same as idle but instead of a\n        relative amount of milliseconds, it sets the idle time to a specific\n        Unix time (in milliseconds).\n\n        retrycount: optional integer. set the retry counter to the specified\n        value. This counter is incremented every time a message is delivered\n        again.\n\n        force: optional boolean, false by default. Creates the pending message\n        entry in the PEL even if certain specified IDs are not already in the\n        PEL assigned to a different client.\n\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/xclaim\n        \"\"\"\n        if not isinstance(min_idle_time, int) or min_idle_time < 0:\n            raise DataError(\"XCLAIM min_idle_time must be a non negative integer\")\n        if not isinstance(message_ids, (list, tuple)) or not message_ids:\n            raise DataError(\n                \"XCLAIM message_ids must be a non empty list or \"\n                \"tuple of message IDs to claim\"\n            )\n\n        kwargs = {}\n        pieces: list[EncodableT] = [name, groupname, consumername, str(min_idle_time)]\n        pieces.extend(list(message_ids))\n\n        if idle is not None:\n            if not isinstance(idle, int):\n                raise DataError(\"XCLAIM idle must be an integer\")\n            pieces.extend((b\"IDLE\", str(idle)))\n        if time is not None:\n            if not isinstance(time, int):\n                raise DataError(\"XCLAIM time must be an integer\")\n            pieces.extend((b\"TIME\", str(time)))","sourceCodeStart":7275,"sourceCodeEnd":7311,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L7275-L7311","documentation":"Raised by Redis.xclaim() when min_idle_time is not an int or is negative. Unlike xautoclaim, this uses a strict isinstance(int) check, so floats and numeric strings are rejected (not just negatives). bool is a subclass of int, so True/1 pass and False/0 pass as 0.","triggerScenarios":"Calling r.xclaim(name, group, consumer, min_idle_time, ids) with min_idle_time as a float (1.5), a string ('100'), None (fails isinstance), or a negative int (-1).","commonSituations":"Passing a float ms value, reading idle from config as a string, or a sign error.","solutions":["Pass an int (milliseconds) >= 0.","Coerce explicitly: min_idle_time = int(float_value) if you need rounding.","Reject bool if it is not semantically valid for your call."],"exampleFix":"# before\nr.xclaim('s','g','c', 1.5, ['1-0'])\n\n# after\nr.xclaim('s','g','c', 2, ['1-0'])","handlingStrategy":"type-guard","validationCode":"if not isinstance(min_idle_time, int) or isinstance(min_idle_time, bool) or min_idle_time < 0:\n    raise TypeError('min_idle_time must be a non-negative int')","typeGuard":"lambda v: isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    r.xclaim('s','g','c', ms, ids)\nexcept DataError as e:\n    log.warning('bad xclaim min_idle_time %r: %s', ms, e)","preventionTips":["Keep min_idle_time as an int throughout your pipeline.","xclaim's type check is stricter than xautoclaim's; do not assume the same value passes both."],"tags":["stream","xclaim","validation","type-check"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}