Skip to content

"bug" about acl_genpass method #3059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NC-Cj opened this issue Dec 1, 2023 · 0 comments · Fixed by #3062
Closed

"bug" about acl_genpass method #3059

NC-Cj opened this issue Dec 1, 2023 · 0 comments · Fixed by #3062
Labels
bug Bug

Comments

@NC-Cj
Copy link

NC-Cj commented Dec 1, 2023

Thanks for wanting to report an issue you've found in redis-py. Please delete this text and fill in the template below.
It is of course not always possible to reduce your code to a small test case, but it's highly appreciated to have as much data as possible. Thank you!

Version: 5.0.1, "bug" about acl_genpass method

Platform: win11

Description: Refer to the following demo

demo:

from redis import Redis

url = "redis://localhost:6379/1"
rdb = Redis.from_url(url)

print(rdb.acl_genpass(32))

This script is similar to ACL GENPASS [bits], we will get an 8-digit password. But what we got didn't meet expectations.

Your source code might get the desired result this way:

    def acl_genpass(self, bits: Union[int, None] = None, **kwargs) -> ResponseT:
        """Generate a random password value.
        If ``bits`` is supplied then use this number of bits, rounded to
        the next multiple of 4.
        See: https://redis.io/commands/acl-genpass
        """
        pieces = []
        if bits is not None:
            try:
                b = int(bits)
                if b < 0 or b > 4096:
                    raise ValueError
                pieces.append(b)
            except ValueError:
                raise DataError(
                    "genpass optionally accepts a bits argument, between 0 and 4096."
                )
        return self.execute_command("ACL GENPASS", *pieces, **kwargs)
@dvora-h dvora-h added the bug Bug label Dec 3, 2023
@dvora-h dvora-h mentioned this issue Dec 3, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants