{"record":{"id":"ecc80f59259619fa","repo":"redis/redis-py","slug":"only-one-of-idmpauto-or-idmp-may-be-sp","errorCode":null,"errorMessage":"Only one of ```idmpauto``` or ```idmp``` may be specified","messagePattern":"Only one of ```idmpauto``` or ```idmp``` may be specified","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":7019,"sourceCode":"            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:\n                raise DataError(\n                    \"XADD idmp must be a tuple of (producer_id, idempotent_id)\"\n                )","sourceCodeStart":7001,"sourceCodeEnd":7037,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L7001-L7037","documentation":"Raised by xadd() when both idmpauto and idmp are provided. idmpauto lets Redis compute an idempotent ID from entry content, while idmp supplies an explicit (producer_id, idempotent_id) pair; only one idempotency mode is allowed per XADD. It is a DataError.","triggerScenarios":"Calling client.xadd('mystream', fields, idmpauto='producer-1', idmp=('producer-1', b'iid')).","commonSituations":"Experimenting with both idempotency modes, or passing both because of an unclear config schema.","solutions":["Use idmpauto for automatic content-derived idempotency, OR idmp=(producer_id, idempotent_id) for explicit control — not both.","Pick idmpauto when you want Redis to dedupe by content hash; pick idmp when you supply your own dedup key."],"exampleFix":"# before\nclient.xadd('s', {'f': 'v'}, idmpauto='p1', idmp=('p1', b'iid'))\n\n# after\nclient.xadd('s', {'f': 'v'}, idmpauto='p1')","handlingStrategy":"validation","validationCode":"if idmpauto is not None and idmp is not None:\n    raise ValueError('Specify only one of idmpauto or idmp')\nclient.xadd(name, fields, idmpauto=idmpauto, idmp=idmp)","typeGuard":null,"tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.xadd(name, fields, idmpauto=idmpauto, idmp=idmp)\nexcept DataError as e:\n    if 'idmpauto' in str(e):\n        idmp = None\n        client.xadd(name, fields, idmpauto=idmpauto)","preventionTips":["Pick one idempotency mode per stream producer and document it.","Prefer idmpauto for content-based dedup; use idmp only when you supply explicit dedup keys."],"tags":["streams","xadd","idempotency","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"}