{"record":{"id":"97ee34f64db7cc2b","repo":"redis/redis-py","slug":"idmpauto-and-idmp-can-only-be-used-with-id","errorCode":null,"errorMessage":"IDMPAUTO and IDMP can only be used with id='*'","messagePattern":"IDMPAUTO and IDMP can only be used with id='\\*'","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":7022,"sourceCode":"            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                )\n            pieces.extend([b\"IDMP\", idmp[0], idmp[1]])\n        if maxlen is not None:\n            if not isinstance(maxlen, int) or maxlen < 0:","sourceCodeStart":7004,"sourceCodeEnd":7040,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L7004-L7040","documentation":"Raised by xadd() when idmpauto or idmp is used together with an explicit id other than '*'. Idempotent ID calculation requires Redis to generate the entry ID, so the id must be the default wildcard '*'. It is a DataError.","triggerScenarios":"Calling client.xadd('mystream', fields, id='1234-0', idmpauto='p1'), or client.xadd('mystream', fields, id='1234-0', idmp=('p1', b'iid')).","commonSituations":"Setting a custom id for ordering and then trying to add idempotency, or carrying over an explicit id from a non-idempotent call.","solutions":["Omit the id argument (it defaults to '*') when using idmpauto or idmp.","If you must supply a specific entry ID, you cannot use idempotency — drop idmpauto/idmp."],"exampleFix":"# before\nclient.xadd('s', {'f': 'v'}, id='1234-0', idmpauto='p1')\n\n# after\nclient.xadd('s', {'f': 'v'}, idmpauto='p1')","handlingStrategy":"validation","validationCode":"if (idmpauto is not None or idmp is not None) and id != '*':\n    raise ValueError(\"idempotency requires id='*' (auto-generated)\")\nclient.xadd(name, fields, id=id, idmpauto=idmpauto, idmp=idmp)","typeGuard":null,"tryCatchPattern":"from redis.exceptions import DataError\ntry:\n    client.xadd(name, fields, id=id, idmpauto=idmpauto)\nexcept DataError as e:\n    if \"id='*'\" in str(e):\n        client.xadd(name, fields, idmpauto=idmpauto)  # id defaults to '*'","preventionTips":["When enabling idempotency, omit the id argument entirely so it defaults to '*'.","Remember that explicit entry IDs are incompatible with IDMP — choose one."],"tags":["streams","xadd","idempotency","validation","dependency"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}