Skip to content
Latchkey

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.

redis-cli
(error) ERR wrong number of arguments for 'set' command

Common 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

  1. Wrap any multi-word value in quotes so it stays a single argument.
  2. Quote variable expansions used as values.
  3. Re-run the command and confirm it returns OK.
Terminal
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.

Terminal
redis-cli set session:1 "$PAYLOAD" EX 60

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →