redis/redis-py · error · DataError

ACL LOG count must be an integer

Error message

ACL LOG count must be an integer

What it means

Raised by acl_log() as a DataError when count is supplied but is not an int (isinstance(count, int) is False at redis/commands/core.py:290). The guard is strict type-based, not conversion-based — a float like 5.0 or a numeric string '5' is rejected even though they look numeric. Note bool is a subclass of int and would slip through.

Source

Thrown at redis/commands/core.py:291

    @overload
    def acl_log(
        self: AsyncClientProtocol, count: int | None = None, **kwargs
    ) -> Awaitable[ACLLogData]: ...

    def acl_log(
        self, count: int | None = None, **kwargs
    ) -> ACLLogData | Awaitable[ACLLogData]:
        """
        Get ACL logs as a list.
        :param int count: Get logs[0:count].
        :rtype: List.

        For more information, see https://redis.io/commands/acl-log
        """
        args = []
        if count is not None:
            if not isinstance(count, int):
                raise DataError("ACL LOG count must be an integer")
            args.append(count)

        return self.execute_command("ACL LOG", *args, **kwargs)

    @overload
    def acl_log_reset(self: SyncClientProtocol, **kwargs) -> bool: ...

    @overload
    def acl_log_reset(self: AsyncClientProtocol, **kwargs) -> Awaitable[bool]: ...

    def acl_log_reset(self, **kwargs) -> bool | Awaitable[bool]:
        """
        Reset ACL logs.
        :rtype: Boolean.

        For more information, see https://redis.io/commands/acl-log
        """
        args = [b"RESET"]

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Pass a real int, e.g. r.acl_log(int(count)).
  2. Coerce at the boundary: count = int(count) before calling, after confirming it is numeric.
  3. If count may be a string from HTTP input, parse and validate with int() first.

Example fix

# before
r.acl_log(count='20')      # str -> DataError
r.acl_log(count=10.0)      # float -> DataError
# after
r.acl_log(count=int('20'))
r.acl_log(count=int(10.0))
Defensive patterns

Strategy: type-guard

Validate before calling

if count is not None and not isinstance(count, int):
    count = int(count)  # or raise for the caller
client.acl_log(count=count)

Type guard

def is_int_count(count) -> bool:
    return count is None or (isinstance(count, int) and not isinstance(count, bool))

Try / catch

from redis.exceptions import DataError
try:
    client.acl_log(count=count)
except DataError:
    client.acl_log(count=int(count))

Prevention

When it happens

Trigger: Calling r.acl_log(count) where count is a float (5.0), a string ('10'), a Decimal, or any non-int numeric. Passing None is fine (count omitted). Passing a bool is technically accepted due to int subclassing.

Common situations: count sourced from JSON/config as a string or float; division/computation producing a float that is then passed directly; API layer forwarding query params as strings.

Related errors


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