redis/redis-py · error · DataError
IDMPAUTO and IDMP can only be used with id='*'
Error message
IDMPAUTO and IDMP can only be used with id='*'
What it means
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.
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.
Example fix
# before
client.xadd('s', {'f': 'v'}, id='1234-0', idmpauto='p1')
# after
client.xadd('s', {'f': 'v'}, idmpauto='p1') Defensive patterns
Strategy: validation
Validate before calling
if (idmpauto is not None or idmp is not None) and id != '*':
raise ValueError("idempotency requires id='*' (auto-generated)")
client.xadd(name, fields, id=id, idmpauto=idmpauto, idmp=idmp) Try / catch
from redis.exceptions import DataError
try:
client.xadd(name, fields, id=id, idmpauto=idmpauto)
except DataError as e:
if "id='*'" in str(e):
client.xadd(name, fields, idmpauto=idmpauto) # id defaults to '*' Prevention
- When enabling idempotency, omit the id argument entirely so it defaults to '*'.
- Remember that explicit entry IDs are incompatible with IDMP — choose one.
When it happens
Trigger: Calling client.xadd('mystream', fields, id='1234-0', idmpauto='p1'), or client.xadd('mystream', fields, id='1234-0', idmp=('p1', b'iid')).
Common situations: Setting a custom id for ordering and then trying to add idempotency, or carrying over an explicit id from a non-idempotent call.
Related errors
- Only one of ```idmpauto``` or ```idmp``` may be specified
- XADD idmp must be a tuple of (producer_id, idempotent_id)
- Only one of ```maxlen``` or ```minid``` may be specified
- XADD fields must be a non-empty dict
- XADD maxlen must be non-negative integer
AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10).
Data as JSON: /api/errors/97ee34f64db7cc2b.
Report an issue: GitHub.
Appendix: source
Thrown at redis/commands/core.py:7022
across restarts.
idmp: Tuple of (producer_id, idempotent_id) for explicit idempotent ID.
Uses a specific idempotent ID to prevent duplicate entries. Can only be used
with id='*'. The producer ID must be unique per producer and consistent across
restarts. The idempotent ID must be unique per message and per producer.
Shorter idempotent IDs require less memory and allow faster processing.
Creates an IDMP map if it doesn't exist yet.
For more information, see https://redis.io/commands/xadd
"""
pieces: list[EncodableT] = []
if maxlen is not None and minid is not None:
raise DataError("Only one of ```maxlen``` or ```minid``` may be specified")
if idmpauto is not None and idmp is not None:
raise DataError("Only one of ```idmpauto``` or ```idmp``` may be specified")
if (idmpauto is not None or idmp is not None) and id != "*":
raise DataError("IDMPAUTO and IDMP can only be used with id='*'")
if ref_policy is not None and ref_policy not in {"KEEPREF", "DELREF", "ACKED"}:
raise DataError("XADD ref_policy must be one of: KEEPREF, DELREF, ACKED")
if nomkstream:
pieces.append(b"NOMKSTREAM")
if ref_policy is not None:
pieces.append(ref_policy)
if idmpauto is not None:
pieces.extend([b"IDMPAUTO", idmpauto])
if idmp is not None:
if not isinstance(idmp, tuple) or len(idmp) != 2:
raise DataError(
"XADD idmp must be a tuple of (producer_id, idempotent_id)"
)
pieces.extend([b"IDMP", idmp[0], idmp[1]])
if maxlen is not None:
if not isinstance(maxlen, int) or maxlen < 0:View on GitHub (pinned to 6a6b581b48)