redis/redis-py · error · DataError

XCFGSET idmp_maxsize must be an integer between 1 and…

Error message

XCFGSET idmp_maxsize must be an integer between 1 and 1,000,000

What it means

Raised by Redis.xcfgset() when idmp_maxsize is not an int, or is outside [1, 1,000,000]. idmp_maxsize caps how many idempotency IDs the server tracks; sized roughly as mark-delay(ms) * messages-per-ms + margin. Validated client-side; None skips the check.

Solutions

  1. Pass an int within [1, 1_000_000].
  2. Clamp computed values: idmp_maxsize=max(1, min(1_000_000, int(computed))).
  3. Coerce string config with int() before calling.

Example fix

# before
r.xcfgset('mystream', idmp_maxsize=1_500_000)

# after
r.xcfgset('mystream', idmp_maxsize=1_000_000)
Defensive patterns

Strategy: validation

Validate before calling

def valid_idmp_maxsize(v):
    return v is None or (isinstance(v, int) and not isinstance(v, bool) and 1 <= v <= 1_000_000)

if not valid_idmp_maxsize(idmp_maxsize):
    raise ValueError('idmp_maxsize must be int in [1,1000000]')

Type guard

lambda v: v is None or (isinstance(v, int) and not isinstance(v, bool) and 1 <= v <= 1_000_000)

Try / catch

from redis.exceptions import DataError
try:
    r.xcfgset('mystream', idmp_maxsize=ms)
except DataError as e:
    log.warning('bad idmp_maxsize %r: %s', ms, e)

Prevention

When it happens

Trigger: Calling r.xcfgset('mystream', idmp_maxsize=<v>) where <v> is a float/string, or an int <1 or >1_000_000 (e.g. 0, -5, 2_000_000). Guard: `not isinstance(idmp_maxsize, int) or v < 1 or v > 1000000`.

Common situations: Computing maxsize from throughput/delay and rounding to a value over the cap, loading it as a string from config, or passing 0 to 'disable'.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/6abe3c1f288fb3c1. Report an issue: GitHub.

Appendix: source

Thrown at redis/commands/core.py:7133

        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 (
                not isinstance(idmp_maxsize, int)
                or idmp_maxsize < 1
                or idmp_maxsize > 1000000
            ):
                raise DataError(
                    "XCFGSET idmp_maxsize must be an integer between 1 and 1,000,000"
                )
            pieces.extend([b"IDMP-MAXSIZE", idmp_maxsize])

        return self.execute_command("XCFGSET", name, *pieces)

    @overload
    def xautoclaim(
        self: SyncClientProtocol,
        name: KeyT,
        groupname: GroupT,
        consumername: ConsumerT,
        min_idle_time: int,
        start_id: StreamIdT = "0-0",
        count: int | None = None,
        justid: bool = False,
    ) -> list[Any]: ...

View on GitHub (pinned to 6a6b581b48)