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 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.

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 da03cdc7e8)

Solutions

  1. Omit id (defaults to '*') when using idmpauto or idmp.
  2. If you must supply an explicit id, drop the idempotency arguments.
  3. Ensure your idempotency-enabled writes always let Redis assign the entry ID.

Example fix

# before
await r.xadd('s', {'f': 'v'}, id='1234-0', idmpauto='p1')
# after
await r.xadd('s', {'f': 'v'}, idmpauto='p1')
Defensive patterns

Strategy: validation

Validate before calling

def validate_idmp_requires_auto_id(id, idmpauto, idmp):
    if (idmpauto is not None or idmp is not None) and id != '*':
        raise ValueError("IDMPAUTO and IDMP require id='*'")
    return True

Prevention

When it happens

Trigger: Calling client.xadd(name, fields, id='1234-0', idmpauto='prod-1') or client.xadd(name, fields, id='1234-0', idmp=('prod-1', b'abc')).

Common situations: Setting a fixed id for ordering while also wanting dedup; forgetting that idempotency mandates id='*'.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/97ee34f64db7cc2b.json. Report an issue: GitHub.