{"record":{"id":"424696bcaa91cbb1","repo":"redis/redis-py","slug":"ordering-obo-or-bulk-is-required-when-coun","errorCode":null,"errorMessage":"``ordering`` (OBO or BULK) is required when ``count`` is set","messagePattern":"``ordering`` \\(OBO or BULK\\) is required when ``count`` is set","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":3676,"sourceCode":"        ``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\",\n        dest: str = \"RIGHT\",\n        count: int | None = None,\n        mode: Literal[\"COUNT\", \"EXACTLY\"] | None = None,\n        ordering: Literal[\"OBO\", \"BULK\"] | None = None,","sourceCodeStart":3658,"sourceCodeEnd":3694,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L3658-L3694","documentation":"Raised as a `DataError` by `lmovem()` (redis/commands/core.py:3675) when `count` is set but `ordering` is `None`. Multi-element LMOVEM requires an explicit destination ordering — `OBO` (one-by-one, stack semantics) or `BULK` (preserve order, queue semantics) — because the server cannot guess push semantics.","triggerScenarios":"`r.lmovem('a', 'b', count=3)`, or any LMOVEM call that supplies count but omits ordering (mode is optional and defaults to COUNT).","commonSituations":"Forwarding only count from a caller; assuming a default ordering; refactoring from LMPOP-style code.","solutions":["Always pass `ordering='OBO'` or `ordering='BULK'` together with `count`.","Choose `OBO` to reverse block order at the destination, `BULK` to preserve it.","Drop `count` if you only want a single-element move."],"exampleFix":"// before\nr.lmovem('src', 'dst', count=3)\n// after\nr.lmovem('src', 'dst', count=3, ordering='BULK')  # preserve relative order","handlingStrategy":"validation","validationCode":"if count is not None and ordering is None:\n    raise ValueError(\"lmovem: ordering must be 'OBO' or 'BULK' when count is set\")\nr.lmovem('a', 'b', count=count, ordering=ordering)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify ordering together with count.","Pick OBO vs BULK deliberately based on stack vs queue semantics."],"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"}