{"record":{"id":"2cd86443d1a4b1a8","repo":"redis/redis-py","slug":"count-is-required-when-mode-or-ordering","errorCode":null,"errorMessage":"``count`` is required when ``mode`` or ``ordering`` is set","messagePattern":"``count`` is required when ``mode`` or ``ordering`` is set","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":3672,"sourceCode":"        ``LEFT`` (head) or ``RIGHT`` (tail).\n\n        When ``count`` is given, ``mode`` selects how many elements to move:\n        ``COUNT`` (the default) moves up to ``count`` elements, while\n        ``EXACTLY`` moves exactly ``count`` elements or nothing at all. When\n        ``count`` is not given a single element is moved.\n\n        ``ordering`` controls the order at the destination: ``OBO`` pushes each\n        element as it is popped (reversing block order, stack semantics) while\n        ``BULK`` preserves the original relative order (queue semantics). It is\n        required whenever ``count`` is given.\n\n        Returns the array of moved elements, or ``None`` if nothing was moved.\n\n        For more information, see https://redis.io/commands/lmovem\n        \"\"\"\n        if count is None:\n            if mode is not None or ordering is not None:\n                raise DataError(\n                    \"``count`` is required when ``mode`` or ``ordering`` is set\"\n                )\n        elif ordering is None:\n            raise DataError(\n                \"``ordering`` (OBO or BULK) is required when ``count`` is set\"\n            )\n        pieces: list[EncodableT] = [first_list, second_list, src, dest]\n        if count is not None:\n            pieces.extend([mode or \"COUNT\", count, ordering])\n        return self.execute_command(\"LMOVEM\", *pieces)\n\n    @overload\n    def blmovem(\n        self: SyncClientProtocol,\n        first_list: str,\n        second_list: str,\n        timeout: float,\n        src: str = \"LEFT\",","sourceCodeStart":3654,"sourceCodeEnd":3690,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L3654-L3690","documentation":"Raised as a `DataError` by `lmovem()` (redis/commands/core.py:3671) when `count` is `None` but `mode` or `ordering` is supplied. LMOVEM's multi-element mode is only meaningful together with a count; specifying mode/ordering without a count is rejected.","triggerScenarios":"`r.lmovem('a', 'b', mode='EXACTLY')`, `r.lmovem('a', 'b', ordering='BULK')`, or any LMOVEM call that sets mode/ordering but omits count.","commonSituations":"Building kwargs conditionally and setting mode/ordering in a branch that forgot count; assuming defaults fill in count; experimental API (LMOVEM is new).","solutions":["When you set `mode` or `ordering`, also pass `count` (a positive int).","Drop `mode`/`ordering` for single-element moves (no count).","Treat count, mode, and ordering as a single resolved group before calling."],"exampleFix":"// before\nr.lmovem('src', 'dst', mode='EXACTLY')\n// after\nr.lmovem('src', 'dst', count=3, mode='EXACTLY', ordering='BULK')","handlingStrategy":"validation","validationCode":"if count is None and (mode is not None or ordering is not None):\n    raise ValueError('lmovem: count is required when mode/ordering is set')\nr.lmovem('a', 'b', count=count, mode=mode, ordering=ordering)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bundle (count, mode, ordering) as one optional group.","Omit all three for a single-element move."],"tags":["lmovem","arguments","validation","lists","dataerror"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}