{"record":{"id":"0555116dea76d609","repo":"redis/redis-py","slug":"only-one-of-maxlen-or-minid-may-be-spe","errorCode":null,"errorMessage":"Only one of ```maxlen``` or ```minid``` may be specified","messagePattern":"Only one of ```maxlen``` or ```minid``` may be specified","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":7016,"sourceCode":"            - DELREF: When trimming, removes all references from consumer groups' PEL\n            - ACKED: When trimming, only removes entries acknowledged by all consumer groups\n        idmpauto: Producer ID for automatic idempotent ID calculation.\n            Automatically calculates an idempotent ID based on entry content to prevent\n            duplicate entries. Can only be used with id='*'. Creates an IDMP map if it\n            doesn't exist yet. The producer ID must be unique per producer and consistent\n            across restarts.\n        idmp: Tuple of (producer_id, idempotent_id) for explicit idempotent ID.\n            Uses a specific idempotent ID to prevent duplicate entries. Can only be used\n            with id='*'. The producer ID must be unique per producer and consistent across\n            restarts. The idempotent ID must be unique per message and per producer.\n            Shorter idempotent IDs require less memory and allow faster processing.\n            Creates an IDMP map if it doesn't exist yet.\n\n        For more information, see https://redis.io/commands/xadd\n        \"\"\"\n        pieces: list[EncodableT] = []\n        if maxlen is not None and minid is not None:\n            raise DataError(\"Only one of ```maxlen``` or ```minid``` may be specified\")\n\n        if idmpauto is not None and idmp is not None:\n            raise DataError(\"Only one of ```idmpauto``` or ```idmp``` may be specified\")\n\n        if (idmpauto is not None or idmp is not None) and id != \"*\":\n            raise DataError(\"IDMPAUTO and IDMP can only be used with id='*'\")\n\n        if ref_policy is not None and ref_policy not in {\"KEEPREF\", \"DELREF\", \"ACKED\"}:\n            raise DataError(\"XADD ref_policy must be one of: KEEPREF, DELREF, ACKED\")\n\n        if nomkstream:\n            pieces.append(b\"NOMKSTREAM\")\n        if ref_policy is not None:\n            pieces.append(ref_policy)\n        if idmpauto is not None:\n            pieces.extend([b\"IDMPAUTO\", idmpauto])\n        if idmp is not None:\n            if not isinstance(idmp, tuple) or len(idmp) != 2:","sourceCodeStart":6998,"sourceCodeEnd":7034,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L6998-L7034","documentation":"Raised by xadd() when both maxlen and minid are specified. MAXLEN trims the stream by count and MINID trims by entry ID; these are mutually exclusive trimming strategies for XADD. It is a DataError.","triggerScenarios":"Calling client.xadd('mystream', fields, maxlen=1000, minid='1234-0'), or passing both through a config object.","commonSituations":"Combining count-based and ID-based trimming in one call, or migrating from maxlen to minid and forgetting to remove the old parameter.","solutions":["Choose one trimming strategy: use maxlen for count-based trimming or minid for ID-based trimming.","If you need both constraints, trim in a separate call (e.g. client.xtrim with one criterion)."],"exampleFix":"# before\nclient.xadd('mystream', {'f': 'v'}, maxlen=1000, minid='1234-0')\n\n# after\nclient.xadd('mystream', {'f': 'v'}, minid='1234-0')","handlingStrategy":"validation","validationCode":"if maxlen is not None and minid is not None:\n    raise ValueError('Specify only one of maxlen or minid for trimming')\nclient.xadd(name, fields, maxlen=maxlen, minid=minid)","typeGuard":null,"tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.xadd(name, fields, maxlen=maxlen, minid=minid)\nexcept DataError as e:\n    if 'maxlen' in str(e) and 'minid' in str(e):\n        minid = None\n        client.xadd(name, fields, maxlen=maxlen)","preventionTips":["Decide trimming strategy once per stream (count vs ID) and store only that parameter.","Do not carry both maxlen and minid through a shared config object."],"tags":["streams","xadd","trimming","mutual-exclusivity","validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}