{"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/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/commands/core.py#L7004-L7040","documentation":"Raised by xadd() when idmpauto or idmp is provided but id is not the default '*'. Idempotency works by letting Redis derive or map the entry ID from the idempotent token, which requires the entry ID to be auto-generated; supplying an explicit id conflicts with that mechanism.","triggerScenarios":"Calling client.xadd(name, fields, id='1234-0', idmpauto='prod-1') or client.xadd(name, fields, id='1234-0', idmp=('prod-1', b'abc')).","commonSituations":"Setting a fixed id for ordering while also wanting dedup; forgetting that idempotency mandates id='*'.","solutions":["Omit id (defaults to '*') when using idmpauto or idmp.","If you must supply an explicit id, drop the idempotency arguments.","Ensure your idempotency-enabled writes always let Redis assign the entry ID."],"exampleFix":"# before\nawait r.xadd('s', {'f': 'v'}, id='1234-0', idmpauto='p1')\n# after\nawait r.xadd('s', {'f': 'v'}, idmpauto='p1')","handlingStrategy":"validation","validationCode":"def validate_idmp_requires_auto_id(id, idmpauto, idmp):\n    if (idmpauto is not None or idmp is not None) and id != '*':\n        raise ValueError(\"IDMPAUTO and IDMP require id='*'\")\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit id (defaults to '*') whenever using idempotency.","Never combine an explicit entry id with idmp/idmpauto.","Treat idempotent writes as auto-ID writes."],"tags":["stream","xadd","idempotency","validation","dataerror"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}