{"record":{"id":"59d13e4e455f7e12","repo":"redis/redis-py","slug":"xclaim-message-ids-must-be-a-non-empty-list-or-tup","errorCode":null,"errorMessage":"XCLAIM message_ids must be a non empty list or tuple of message IDs to claim","messagePattern":"XCLAIM message_ids must be a non empty list or tuple of message IDs to claim","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":7295,"sourceCode":"        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)))\n        if retrycount is not None:\n            if not isinstance(retrycount, int):","sourceCodeStart":7277,"sourceCodeEnd":7313,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L7277-L7313","documentation":"Raised by Redis.xclaim() when message_ids is not a list or tuple, or is an empty list/tuple. The check is `not isinstance(message_ids, (list, tuple)) or not message_ids`. A single bare ID string, a set, a generator, None, or [] all fail.","triggerScenarios":"Calling r.xclaim(name, group, consumer, ms, '1-0') (string not list), r.xclaim(..., []) (empty), r.xclaim(..., {'1-0'}) (set), or passing a generator/iterator.","commonSituations":"Forgetting to wrap a single ID in a list, unpacking an empty result from XPENDING, or passing a set for 'deduplication'.","solutions":["Pass a non-empty list or tuple of IDs, e.g. ['1-0', '2-0'].","Guard empties: if not ids: skip the claim.","Convert sets/generators to list before calling."],"exampleFix":"# before\nr.xclaim('s','g','c', 0, pending_ids)  # pending_ids == []\n\n# after\nif pending_ids:\n    r.xclaim('s','g','c', 0, list(pending_ids))","handlingStrategy":"type-guard","validationCode":"if not isinstance(message_ids, (list, tuple)) or len(message_ids) == 0:\n    raise ValueError('message_ids must be a non-empty list/tuple')\nmessage_ids = list(message_ids)","typeGuard":"lambda v: isinstance(v, (list, tuple)) and len(v) > 0","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    r.xclaim('s','g','c', 0, ids)\nexcept DataError as e:\n    if not ids:\n        pass  # nothing to claim, expected\n    else:\n        raise","preventionTips":["Always wrap IDs in a list/tuple, even for a single message.","Short-circuit when the pending list is empty instead of calling xclaim."],"tags":["stream","xclaim","validation","argument-shape"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}