StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

Execute should check for whitespace (was: ACL Management)

Open NArnott opened this issue 1 year ago • 3 comments

I am trying to manage ACLs programmatically, but can't seem to figure out how to do it. Is that possible at this point? I'm aware that ACLs aren't supported yet, but I'm not sure why executing raw commands are an issue.

Something as simple as this:

database.Execute("ACL SETUSER test");

Results in this error:

StackExchange.Redis.RedisServerException: 'ERR unknown command 'ACL SETUSER TEST', with args beginning with: '

All the ACL commands seem to do this.

Longer commands like

$"ACL SETUSER {username} on >{password} +@subscribe +@psubscribe &mychannels*"

results in

System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values. (Parameter 'Command 'ACL SETUSER  on > +@subscribe +@psubscribe &mychannels*' exceeds library limit of 31 bytes')'

If ACLs worked at all, I could get around that latter error by making multiple, shorter commands, though I'd prefer running a single command.

NArnott avatar Apr 01 '24 05:04 NArnott

Execute("ACL", "SETUSER", "test")

Or

Execute("ACL", [ "SETUSER", "test" ])

I wonder if we should detect commands with a space in and either throw a clear exception, or actively split it into pieces and issue what the user probably intended.

mgravell avatar Apr 01 '24 05:04 mgravell

Ah, ok. I couldn't find any documentation on how the args work for the Execute method. I assumed it was similar to how SQL commands do args. Thanks for the clarification.

NArnott avatar Apr 01 '24 14:04 NArnott

Reopening as usability bug. We should detect space in the command an issue appropriate guidance in an exception

mgravell avatar Apr 01 '24 15:04 mgravell