From d1b3276b55a2b6a41ef9639390a1c48b625f703d Mon Sep 17 00:00:00 2001 From: Wen Hui Date: Tue, 2 Aug 2022 21:19:53 -0400 Subject: [PATCH] Fix function load error message (#10964) Update error messages for function load (cherry picked from commit beb9746a9f5f3df198c1b655b7f024b610d9371c) --- src/functions.c | 8 ++++---- tests/unit/functions.tcl | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/functions.c b/src/functions.c index 688d9f5c6..1e81bf6bc 100644 --- a/src/functions.c +++ b/src/functions.c @@ -245,7 +245,7 @@ functionsLibCtx* functionsLibCtxCreate() { */ int functionLibCreateFunction(sds name, void *function, functionLibInfo *li, sds desc, uint64_t f_flags, sds *err) { if (functionsVerifyName(name) != C_OK) { - *err = sdsnew("Function names can only contain letters and numbers and must be at least one character long"); + *err = sdsnew("Library names can only contain letters, numbers, or underscores(_) and must be at least one character long"); return C_ERR; } @@ -819,7 +819,7 @@ void functionFlushCommand(client *c) { /* FUNCTION HELP */ void functionHelpCommand(client *c) { const char *help[] = { -"LOAD [REPLACE] [DESCRIPTION ] ", +"LOAD [REPLACE] ", " Create a new library with the given library name and code.", "DELETE ", " Delete the given library.", @@ -847,7 +847,7 @@ void functionHelpCommand(client *c) { " * ASYNC: Asynchronously flush the libraries.", " * SYNC: Synchronously flush the libraries.", "DUMP", -" Returns a serialized payload representing the current libraries, can be restored using FUNCTION RESTORE command", +" Return a serialized payload representing the current libraries, can be restored using FUNCTION RESTORE command", "RESTORE [FLUSH|APPEND|REPLACE]", " Restore the libraries represented by the given payload, it is possible to give a restore policy to", " control how to handle existing libraries (default APPEND):", @@ -961,7 +961,7 @@ sds functionsCreateWithLibraryCtx(sds code, int replace, sds* err, functionsLibC } if (functionsVerifyName(md.name)) { - *err = sdsnew("Library names can only contain letters and numbers and must be at least one character long"); + *err = sdsnew("Library names can only contain letters, numbers, or underscores(_) and must be at least one character long"); goto error; } diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index a1f6acdff..a907badbe 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -38,7 +38,7 @@ start_server {tags {"scripting"}} { r function load [get_function_code LUA {bad\0foramat} test {return 'hello1'}] } e set _ $e - } {*Library names can only contain letters and numbers*} + } {*Library names can only contain letters, numbers, or underscores(_)*} test {FUNCTION - Create library with unexisting engine} { catch { @@ -597,7 +597,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*Function names can only contain letters and numbers and must be at least one character long*} + } {*Library names can only contain letters, numbers, or underscores(_) and must be at least one character long*} test {LIBRARIES - test registration with empty name} { catch { @@ -606,7 +606,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*Function names can only contain letters and numbers and must be at least one character long*} + } {*Library names can only contain letters, numbers, or underscores(_) and must be at least one character long*} test {LIBRARIES - math.random from function load} { catch {