redis/redis-py · error · DataError

Only one of ```idmpauto``` or ```idmp``` may be specified

Error message

Only one of ```idmpauto``` or ```idmp``` may be specified

What it means

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.

Source

Thrown at redis/commands/core.py:7019

            Automatically calculates an idempotent ID based on entry content to prevent
            duplicate entries. Can only be used with id='*'. Creates an IDMP map if it
            doesn't exist yet. The producer ID must be unique per producer and consistent
            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)"
                )

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Use idmpauto (string producer ID) for automatic content-based dedup, OR idmp ((producer_id, idempotent_id) tuple) for explicit dedup, not both.
  2. Pick one idempotency strategy per producer and pass only the corresponding argument.
  3. Audit call sites that forward both kwargs from a shared config object.

Example fix

# before
await r.xadd('s', {'f': 'v'}, id='*', idmpauto='p1', idmp=('p1', b'x'))
# after
await r.xadd('s', {'f': 'v'}, id='*', idmpauto='p1')
Defensive patterns

Strategy: validation

Validate before calling

def validate_idempotency_mode(idmpauto, idmp):
    if idmpauto is not None and idmp is not None:
        raise ValueError('Specify idmpauto OR idmp, not both')
    return True

Prevention

When it happens

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

Common situations: Migrating from explicit to automatic idempotency without removing the old argument; configuration overlap where both modes are set.

Related errors


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