From 8dcc8ebba4e83ac5eaddc3628e8b4bea9287edcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20S=C3=B6derqvist?= Date: Tue, 16 Apr 2024 21:17:38 +0200 Subject: [PATCH] Remove 'Redis' in error replies (#206) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Low-risk error replies containing "Redis" are changed. In most cases, the word "Redis" is simply removed from the error message, such as in "This Redis instance is not configured to use an ACL file. (...)", the message is changed to "This instance is not configured to use an ACL file. (...)". Additionally, error replies from `redis.call` in a Lua script are affected, such as * "Please specify at least one argument for this redis lib call" * "Wrong number of args calling Redis command from script" * "Unknown Redis command called from script" * "Invalid command passed to redis.acl_check_cmd()" The name Redis is simply removed from these error message. In the last one above, "redis.acl_check_cmd()" is replaced by "server.acl_check_cmd()" in the error message. The following error replies are considered high of causing problems for clients, so they are not changed in this commit: * (not in scope) "-MISCONF Redis is configured to save RDB snapshots (...)" * (not in scope) "-LOADING Redis is loading the dataset in memory" * (not in scope) "-BUSY Redis is busy running a script (...)" Fixes #204 --------- Signed-off-by: Viktor Söderqvist --- src/acl.c | 2 +- src/config.c | 6 +++--- src/replication.c | 2 +- src/script.c | 4 ++-- src/script_lua.c | 6 +++--- tests/unit/acl.tcl | 2 +- tests/unit/scripting.tcl | 12 ++++++------ 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/acl.c b/src/acl.c index d9577b2124..787ef170e4 100644 --- a/src/acl.c +++ b/src/acl.c @@ -2999,7 +2999,7 @@ void aclCommand(client *c) { } else if (server.acl_filename[0] == '\0' && (!strcasecmp(sub,"load") || !strcasecmp(sub,"save"))) { - addReplyError(c,"This Redis instance is not configured to use an ACL file. You may want to specify users via the ACL SETUSER command and then issue a CONFIG REWRITE (assuming you have a Redis configuration file set) in order to store users in the Redis configuration."); + addReplyError(c,"This instance is not configured to use an ACL file. You may want to specify users via the ACL SETUSER command and then issue a CONFIG REWRITE (assuming you have a configuration file set) in order to store users in the configuration."); return; } else if (!strcasecmp(sub,"load") && c->argc == 2) { sds errors = ACLLoadFromFile(server.acl_filename); diff --git a/src/config.c b/src/config.c index d3da3f94e5..fcc53af13b 100644 --- a/src/config.c +++ b/src/config.c @@ -2339,8 +2339,8 @@ static int isValidActiveDefrag(int val, const char **err) { #ifndef HAVE_DEFRAG if (val) { *err = "Active defragmentation cannot be enabled: it " - "requires a Redis server compiled with a modified Jemalloc " - "like the one shipped by default with the Redis source " + "requires a server compiled with a modified Jemalloc " + "like the one shipped by default with the source " "distribution"; return 0; } @@ -2564,7 +2564,7 @@ static int updateMaxclients(const char **err) { if (aeResizeSetSize(server.el, server.maxclients + CONFIG_FDSET_INCR) == AE_ERR) { - *err = "The event loop API used by Redis is not able to handle the specified number of clients"; + *err = "The event loop API is not able to handle the specified number of clients"; return 0; } } diff --git a/src/replication.c b/src/replication.c index f68c550983..361fee786e 100644 --- a/src/replication.c +++ b/src/replication.c @@ -3540,7 +3540,7 @@ void waitCommand(client *c) { long long offset = c->woff; if (server.masterhost) { - addReplyError(c,"WAIT cannot be used with replica instances. Please also note that since Redis 4.0 if a replica is configured to be writable (which is not the default) writes to replicas are just local and are not propagated."); + addReplyError(c,"WAIT cannot be used with replica instances. Please also note that if a replica is configured to be writable (which is not the default) writes to replicas are just local and are not propagated."); return; } diff --git a/src/script.c b/src/script.c index db42e2f455..0a36bc7ab9 100644 --- a/src/script.c +++ b/src/script.c @@ -322,9 +322,9 @@ void scriptKill(client *c, int is_eval) { static int scriptVerifyCommandArity(struct serverCommand *cmd, int argc, sds *err) { if (!cmd || ((cmd->arity > 0 && cmd->arity != argc) || (argc < -cmd->arity))) { if (cmd) - *err = sdsnew("Wrong number of args calling Redis command from script"); + *err = sdsnew("Wrong number of args calling command from script"); else - *err = sdsnew("Unknown Redis command called from script"); + *err = sdsnew("Unknown command called from script"); return C_ERR; } return C_OK; diff --git a/src/script_lua.c b/src/script_lua.c index 24784c1d85..21bf6f6af9 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -800,7 +800,7 @@ static robj **luaArgsToRedisArgv(lua_State *lua, int *argc, int *argv_len) { /* Require at least one argument */ *argc = lua_gettop(lua); if (*argc == 0) { - luaPushError(lua, "Please specify at least one argument for this redis lib call"); + luaPushError(lua, "Please specify at least one argument for this call"); return NULL; } @@ -859,7 +859,7 @@ static robj **luaArgsToRedisArgv(lua_State *lua, int *argc, int *argv_len) { * integers as well). */ if (j != *argc) { freeLuaRedisArgv(lua_argv, j, lua_argv_size); - luaPushError(lua, "Lua redis lib command arguments must be strings or integers"); + luaPushError(lua, "Command arguments must be strings or integers"); return NULL; } @@ -1146,7 +1146,7 @@ static int luaRedisAclCheckCmdPermissionsCommand(lua_State *lua) { /* Find command */ struct serverCommand *cmd; if ((cmd = lookupCommand(argv, argc)) == NULL) { - luaPushError(lua, "Invalid command passed to redis.acl_check_cmd()"); + luaPushError(lua, "Invalid command passed to server.acl_check_cmd()"); raise_error = 1; } else { int keyidxptr; diff --git a/tests/unit/acl.tcl b/tests/unit/acl.tcl index 2edac213e5..a05359d7c9 100644 --- a/tests/unit/acl.tcl +++ b/tests/unit/acl.tcl @@ -905,7 +905,7 @@ start_server {tags {"acl external:skip"}} { test {ACL load non-existing configured ACL file} { catch {r ACL load} err set err - } {*Redis instance is not configured to use an ACL file*} + } {*instance is not configured to use an ACL file*} # If there is an AUTH failure the metric increases test {ACL-Metrics user AUTH failure} { diff --git a/tests/unit/scripting.tcl b/tests/unit/scripting.tcl index 3fd4190ba8..15d7142fa2 100644 --- a/tests/unit/scripting.tcl +++ b/tests/unit/scripting.tcl @@ -349,7 +349,7 @@ start_server {tags {"scripting"}} { run_script "redis.call('nosuchcommand')" 0 } e set e - } {*Unknown Redis*} + } {*Unknown command*} test {EVAL - redis.call variant raises a Lua error on Redis cmd error (1)} { set e {} @@ -896,8 +896,8 @@ start_server {tags {"scripting"}} { } {ERR Number of keys can't be negative} test {Scripts can handle commands with incorrect arity} { - assert_error "ERR Wrong number of args calling Redis command from script*" {run_script "redis.call('set','invalid')" 0} - assert_error "ERR Wrong number of args calling Redis command from script*" {run_script "redis.call('incr')" 0} + assert_error "ERR Wrong number of args calling command from script*" {run_script "redis.call('set','invalid')" 0} + assert_error "ERR Wrong number of args calling command from script*" {run_script "redis.call('incr')" 0} } test {Correct handling of reused argv (issue #1939)} { @@ -1022,7 +1022,7 @@ start_server {tags {"scripting"}} { } 0] {} # Check error due to invalid command - assert_error {ERR *Invalid command passed to redis.acl_check_cmd()*} {run_script { + assert_error {ERR *Invalid command passed to server.acl_check_cmd()*} {run_script { return redis.acl_check_cmd('invalid-cmd','arg') } 0} } @@ -1542,7 +1542,7 @@ start_server {tags {"scripting needs:debug external:skip"}} { r write $cmd r flush set ret [r read] - assert_match {*Unknown Redis command called from script*} $ret + assert_match {*Unknown command called from script*} $ret # make sure the server is still ok reconnect assert_equal [r ping] {PONG} @@ -2385,7 +2385,7 @@ start_server {tags {"scripting"}} { } test "LUA test pcall with non string/integer arg" { - assert_error "ERR Lua redis lib command arguments must be strings or integers*" { + assert_error "ERR Command arguments must be strings or integers*" { r eval { local x={} return redis.call("ping", x)