Skip to content

Throw a clear error when an Execute command contains whitespace#3122

Open
arpitjain099 wants to merge 1 commit into
StackExchange:mainfrom
arpitjain099:chore/execute-whitespace-guard
Open

Throw a clear error when an Execute command contains whitespace#3122
arpitjain099 wants to merge 1 commit into
StackExchange:mainfrom
arpitjain099:chore/execute-whitespace-guard

Conversation

@arpitjain099

Copy link
Copy Markdown

Fixes #2689, which you reopened as a usability bug. Calling something like db.Execute("ACL SETUSER x") passes the whole line as a single command token, so it goes out as one unknown command and the only feedback is an opaque ERR unknown command from the server. Since a redis command token never has internal whitespace, that call is always a mistake, so the ExecuteMessage constructor now checks for it up front (right alongside the existing too-many-args and command-disabled guards) and throws a RedisCommandException that names the command and points at the correct token-per-argument form.

I couldn't run the integration suite locally without a server, but the guard fires purely client-side in the constructor, so I added unit tests to AdhocMessageRoundTrip that build the message directly (matching the existing disabled-command tests): a few whitespace inputs throw, and Execute("ACL", "SETUSER", "x") still constructs fine.

Happy to switch to auto-splitting instead if you'd prefer that direction, but your reopen comment read as leaning toward the throw, so I went with that.

Execute("ACL SETUSER x") passes a whole command line as the single command
token, which gets sent as one unknown command and comes back as an opaque
server error. Since a redis command token never contains internal whitespace,
this is always a caller mistake, so the ExecuteMessage constructor now fails
fast with an ArgumentException-style RedisCommandException that names the
offending command and shows the correct token-per-argument form. Resolves StackExchange#2689.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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 this pull request may close these issues.

Execute should check for whitespace (was: ACL Management)

1 participant