{"record":{"id":"825521623d1d4b05","repo":"redis/redis-py","slug":"only-one-of-ifeq-ifne-ifdeq-ifdne-may-be-specified","errorCode":null,"errorMessage":"Only one of IFEQ/IFNE/IFDEQ/IFDNE may be specified","messagePattern":"Only one of IFEQ/IFNE/IFDEQ/IFDNE may be specified","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":2932,"sourceCode":"            ifeq match-valu: Optional[Union[bytes, str]] - Delete the key only if its value is equal to match-value\n            ifne match-value: Optional[Union[bytes, str]] - Delete the key only if its value is not equal to match-value\n            ifdeq match-digest: Optional[str] - Delete the key only if the digest of its value is equal to match-digest\n            ifdne match-digest: Optional[str] - Delete the key only if the digest of its value is not equal to match-digest\n\n        Returns:\n            int: 1 if the key was deleted, 0 otherwise.\n        Raises:\n            redis.exceptions.ResponseError: if key exists but is not a string\n                                            and a condition is specified.\n            ValueError: if more than one condition is provided.\n\n\n        Requires Redis 8.4 or greater.\n        For more information, see https://redis.io/commands/delex\n        \"\"\"\n        conds = [x is not None for x in (ifeq, ifne, ifdeq, ifdne)]\n        if sum(conds) > 1:\n            raise ValueError(\"Only one of IFEQ/IFNE/IFDEQ/IFDNE may be specified\")\n\n        pieces = [\"DELEX\", name]\n        if ifeq is not None:\n            pieces += [\"IFEQ\", ifeq]\n        elif ifne is not None:\n            pieces += [\"IFNE\", ifne]\n        elif ifdeq is not None:\n            pieces += [\"IFDEQ\", ifdeq]\n        elif ifdne is not None:\n            pieces += [\"IFDNE\", ifdne]\n\n        return self.execute_command(*pieces)\n\n    @overload\n    def dump(self: SyncClientProtocol, name: KeyT) -> bytes | None: ...\n\n    @overload\n    def dump(self: AsyncClientProtocol, name: KeyT) -> Awaitable[bytes | None]: ...","sourceCodeStart":2914,"sourceCodeEnd":2950,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L2914-L2950","documentation":"Raised as a `ValueError` (note: not `DataError`) by `delex()` (redis/commands/core.py:2931) when more than one of `ifeq`, `ifne`, `ifdeq`, `ifdne` is non-None. DELEX (Redis 8.4+) accepts at most one conditional matcher; the client enforces that before building the command.","triggerScenarios":"`r.delex('k', ifeq='a', ifne='b')`, or any call combining two or more of the conditional keyword arguments.","commonSituations":"Building conditions from a dict via `**conds` where several keys are populated; migrating from a hypothetical 'match any' mental model; experimental API exploration (the method is marked experimental since 7.1).","solutions":["Pass at most one of `ifeq` / `ifne` / `ifdeq` / `ifdne`.","If your config carries several, pick one with priority logic before calling.","Ensure you're on Redis >= 8.4 — DELEX itself requires it."],"exampleFix":"// before\nr.delex('k', ifeq='a', ifne='b')\n// after\nr.delex('k', ifeq='a')  # delete only if value equals 'a'","handlingStrategy":"validation","validationCode":"conds = {'ifeq': ifeq, 'ifne': ifne, 'ifdeq': ifdeq, 'ifdne': ifdne}\nsupplied = {k: v for k, v in conds.items() if v is not None}\nif len(supplied) > 1:\n    raise ValueError(f'delex: only one condition allowed, got {sorted(supplied)}')\nr.delex('k', **supplied)","typeGuard":null,"tryCatchPattern":"try:\n    r.delex('k', ifeq='a')\nexcept ValueError as e:\n    # too many conditions\n    ...","preventionTips":["Model the DELEX condition as a single (op, value) tuple in your code.","Remember DELEX is experimental and needs Redis >= 8.4."],"tags":["delex","arguments","validation","valueerror","experimental","redis-8-4"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}