{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/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 automatically, while idmp supplies an explicit (producer_id, idempotent_id) tuple; these are two alternative idempotency mechanisms and cannot be combined in one XADD.","triggerScenarios":"Calling client.xadd(name, fields, id='*', idmpauto='prod-1', idmp=('prod-1', b'abc')).","commonSituations":"Migrating from explicit to automatic idempotency without removing the old argument; configuration overlap where both modes are set.","solutions":["Use idmpauto (string producer ID) for automatic content-based dedup, OR idmp ((producer_id, idempotent_id) tuple) for explicit dedup, not both.","Pick one idempotency strategy per producer and pass only the corresponding argument.","Audit call sites that forward both kwargs from a shared config object."],"exampleFix":"# before\nawait r.xadd('s', {'f': 'v'}, id='*', idmpauto='p1', idmp=('p1', b'x'))\n# after\nawait r.xadd('s', {'f': 'v'}, id='*', idmpauto='p1')","handlingStrategy":"validation","validationCode":"def validate_idempotency_mode(idmpauto, idmp):\n    if idmpauto is not None and idmp is not None:\n        raise ValueError('Specify idmpauto OR idmp, not both')\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one idempotency mechanism: automatic (idmpauto) or explicit (idmp).","Do not forward both kwargs from a shared config object.","Document the chosen strategy per producer."],"tags":["stream","xadd","idempotency","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}