Skip to content
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

AclInfo: Expect a valid ACL flag #682

Closed
garyhai opened this issue Sep 16, 2022 · 4 comments · Fixed by #685
Closed

AclInfo: Expect a valid ACL flag #682

garyhai opened this issue Sep 16, 2022 · 4 comments · Fixed by #685

Comments

@garyhai
Copy link
Contributor

garyhai commented Sep 16, 2022

Implementation of FromRedisValue for AclInfo misses "allchannels" flag and therefore fail to call conn.acl_getuser with not_convertible_error

use redis::{acl::AclInfo, Client, Commands};

const CONN_INFO: &str = "redis://127.0.0.1";

fn main() {
  let client = Client::open(CONN_INFO).unwrap();
  let mut conn = client.get_connection().unwrap();
  let info: AclInfo = match conn.acl_getuser("default") {
    Err(e) => {
      dbg!(e);
      return;
    }
    Ok(info) => info,
  };
  dbg!(info);
}

output:

[src/main.rs:10] e = Response type not convertible: "Expect a valid ACL flag" (response was [97, 108, 108, 99, 104, 97, 110, 110, 101, 108, 115])

To fix the issue, in acl.rs:

let flags = flags
                    .as_sequence()
                    .ok_or_else(|| {
                        not_convertible_error!(flags, "Expect a bulk response of ACL flags")
                    })?
                    .iter()
                    .map(|flag| match flag {
                        Value::Data(flag) => match flag.as_slice() {
                            b"on" => Ok(Rule::On),
                            b"off" => Ok(Rule::Off),
                            b"allkeys" => Ok(Rule::AllKeys),
                            b"allcommands" => Ok(Rule::AllCommands),
                            b"nopass" => Ok(Rule::NoPass),
                            b"allchannels" => Ok(Rule::Pattern("&*".into()),
                            _ => Err(not_convertible_error!(flag, "Expect a valid ACL flag")),
                        },
@djc
Copy link
Contributor

djc commented Sep 16, 2022

Thanks for the report! Would you mind submitting a PR for this?

@garyhai
Copy link
Contributor Author

garyhai commented Sep 17, 2022

I'd be happy to submit a PR for the bug. But a more complete change involves structural changes to the Rule, causing compatibility issues. And there are more flags to add with latest version of redis. It is best to be carefully designed by professional team.

@djc
Copy link
Contributor

djc commented Sep 19, 2022

I guess as the volunteer maintainer of this crate I would qualify as professional, but I'm also very busy with maintaining a number of other crates in addition to working at my day job. So this is unlikely to get done unless you (or someone else motivated to work on this) can make some progress on it.

@garyhai
Copy link
Contributor Author

garyhai commented Sep 20, 2022

Thank you for your selfless contribution to this project. Let me try to fix this bug without breaking compatibility.

@jaymell jaymell linked a pull request Sep 28, 2022 that will close this issue
jaymell pushed a commit that referenced this issue Sep 28, 2022
Fix bug of unhandled newly defined flags when call acl_getuser.
nonirosenfeldredis pushed a commit to nonirosenfeldredis/redis-rs that referenced this issue Feb 13, 2023
)

Fix bug of unhandled newly defined flags when call acl_getuser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants