redis/redis-py · error · DataError

XCFGSET requires at least one of idmp_duration or idmp_maxsi

Error message

XCFGSET requires at least one of idmp_duration or idmp_maxsize

What it means

Raised by xcfgset() when both idmp_duration and idmp_maxsize are left as None. XCFGSET configures a stream's idempotency tracking; providing no value at all is a no-op, so the client rejects it with DataError before contacting Redis.

Source

Thrown at redis/commands/core.py:7110

            idmp_duration: How long Redis remembers each iid in seconds.
                Default: 100 seconds (or value set by stream-idmp-duration config).
                Minimum: 1 second, Maximum: 300 seconds.
                Redis won't forget an iid for this duration (unless maxsize is reached).
                Should accommodate application crash recovery time.
            idmp_maxsize: Maximum number of iids Redis remembers per producer ID (pid).
                Default: 100 iids (or value set by stream-idmp-maxsize config).
                Minimum: 1 iid, Maximum: 1,000,000 (1M) iids.
                Should be set to: mark-delay [in msec] × (messages/msec) + margin.
                Example: 10K msgs/sec (10 msgs/msec), 80 msec mark-delay
                → maxsize = 10 × 80 + margin = 1000 iids.

        Returns:
            OK on success.

        For more information, see https://redis.io/commands/xcfgset
        """
        if idmp_duration is None and idmp_maxsize is None:
            raise DataError(
                "XCFGSET requires at least one of idmp_duration or idmp_maxsize"
            )

        pieces: list[EncodableT] = []

        if idmp_duration is not None:
            if (
                not isinstance(idmp_duration, int)
                or idmp_duration < 1
                or idmp_duration > 300
            ):
                raise DataError(
                    "XCFGSET idmp_duration must be an integer between 1 and 300"
                )
            pieces.extend([b"IDMP-DURATION", idmp_duration])

        if idmp_maxsize is not None:
            if (

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Pass at least one of idmp_duration (int seconds) or idmp_maxsize (int count).
  2. If you meant to inspect rather than set config, there is no read call here - just omit XCFGSET.
  3. Guard the call: if cfg: r.xcfgset(name, **cfg).

Example fix

# before
r.xcfgset('mystream')
# after
r.xcfgset('mystream', idmp_duration=120, idmp_maxsize=5000)
Defensive patterns

Strategy: validation

Validate before calling

if idmp_duration is None and idmp_maxsize is None:
    raise ValueError('supply at least one of idmp_duration / idmp_maxsize')
r.xcfgset(name, idmp_duration=idmp_duration, idmp_maxsize=idmp_maxsize)

Try / catch

from redis.exceptions import DataError
try:
    r.xcfgset(name, **cfg)
except DataError as e:
    log.warning('skipping XCFGSET, no values: %s', e)

Prevention

When it happens

Trigger: Call r.xcfgset('mystream') with no keyword arguments, or r.xcfgset('mystream', None, None). The check at core.py:7109 is `if idmp_duration is None and idmp_maxsize is None`.

Common situations: Config built from a dict that resolved to empty; copy-pasting a template without filling values; a conditional that set neither branch; calling XCFGSET expecting it to reset to defaults.

Related errors


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