mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix: return an error when invalid number of arguments is passed. (#3584)
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
832b79563d
commit
dc040b53ad
3 changed files with 9 additions and 3 deletions
|
@ -464,9 +464,12 @@ int RedisReplicateCommands(lua_State* lua) {
|
|||
}
|
||||
|
||||
int RedisLogCommand(lua_State* lua) {
|
||||
// if the arguments passed to redis.log are incorrect
|
||||
// we still do not log the error. Therefore, even if
|
||||
// for the no-op case we don't need to parse the arguments
|
||||
int argc = lua_gettop(lua);
|
||||
if (argc < 2) {
|
||||
PushError(lua, "redis.log() requires two arguments or more.");
|
||||
return RaiseError(lua);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -484,6 +484,8 @@ TEST_F(InterpreterTest, Log) {
|
|||
EXPECT_EQ("nil", ser_.res);
|
||||
EXPECT_TRUE(Execute(R"(redis.log(redis.LOG_WARNING, 'warn'))"));
|
||||
EXPECT_EQ("nil", ser_.res);
|
||||
EXPECT_FALSE(Execute(R"(redis.log(redis.LOG_WARNING))"));
|
||||
EXPECT_THAT(error_, testing::HasSubstr("requires two arguments or more"));
|
||||
}
|
||||
|
||||
TEST_F(InterpreterTest, Robust) {
|
||||
|
|
|
@ -57,6 +57,7 @@ def test_script_exists_redis6(r: redis.Redis):
|
|||
|
||||
|
||||
@pytest.mark.parametrize("args", [("a",), tuple("abcdefghijklmn")])
|
||||
@pytest.mark.unsupported_server_types("dragonfly")
|
||||
def test_script_flush_errors_with_args(r, args):
|
||||
with pytest.raises(redis.ResponseError):
|
||||
raw_command(r, "SCRIPT FLUSH %s" % " ".join(args))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue