{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/core.py#L7277-L7313","documentation":"Raised by xclaim() when message_ids is not a list/tuple, or is empty. Strict check at core.py:7294: `not isinstance(message_ids, (list, tuple)) or not message_ids`. A single id string, a set, a generator, or None all fail.","triggerScenarios":"xclaim(..., message_ids=[]), =None, ='1-0' (bare string), =set(), =gen(). Spreading an empty list: message_ids=[] still fails the truthiness test.","commonSituations":"Building ids from a filter that returned nothing and still calling XCLAIM; passing a comma-separated string instead of a list; passing a generator expression; unpacking a variable that happened to be empty.","solutions":["Pass a non-empty list or tuple of id strings.","Skip the XCLAIM call when you have no ids: if not ids: return [].","Materialize generators: list(gen) before passing."],"exampleFix":"# before\nr.xclaim('s','g','c', 1000, pending_ids)  # pending_ids == []\n# after\nif pending_ids:\n    r.xclaim('s','g','c', 1000, list(pending_ids))","handlingStrategy":"type-guard","validationCode":"if not isinstance(message_ids, (list, tuple)) or not message_ids:\n    raise ValueError('message_ids must be a non-empty list/tuple')\nr.xclaim(name, group, consumer, ms, message_ids)","typeGuard":"def is_id_list(v) -> bool:\n    return isinstance(v, (list, tuple)) and len(v) > 0","tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    r.xclaim(name, group, consumer, ms, ids)\nexcept DataError:\n    ids = list(ids) if ids else []\n    if ids: r.xclaim(name, group, consumer, ms, ids)","preventionTips":["Short-circuit: skip XCLAIM when the pending set is empty.","Always pass list(...)/tuple(...) - never bare strings, sets, or generators."],"tags":["redis","streams","xclaim","type-guard","empty-argument"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}