Redis "ERR wrong number of arguments for command" in CI
Redis parsed the command and the argument count is not valid for it: "ERR wrong number of arguments for 'X' command." In CI scripts this is commonly an unquoted value with spaces that the shell split into extra arguments, or a missing required argument.
What this error means
A redis-cli command in a workflow step fails with "ERR wrong number of arguments for 'set' command" (or another command name) even though it works when typed interactively.
(error) ERR wrong number of arguments for 'set' commandCommon causes
Unquoted value split by the shell
A value containing spaces was passed without quotes, so the shell turned one argument into several and the arity check failed.
A missing required argument
The command was invoked without a mandatory argument (for example SET without a value), which Redis rejects.
How to fix it
Quote values that contain spaces
- Wrap any multi-word value in quotes so it stays a single argument.
- Quote variable expansions used as values.
- Re-run the command and confirm it returns OK.
redis-cli set greeting "hello world"
redis-cli set msg "$MESSAGE"Check the command arity
Confirm the command signature; SET needs a key and a value, and options follow after both.
redis-cli set session:1 "$PAYLOAD" EX 60How to prevent it
- Always quote values (and variable expansions) in shell-invoked redis-cli.
- Check each command signature before scripting it.
- Prefer a client library over shelling out for complex values.