From: Willy Tarreau Date: Fri, 12 Mar 2021 10:53:19 +0000 (+0100) Subject: CLEANUP: vars: make the error message clearer on missing arguments for set-var X-Git-Tag: v2.4-dev12~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d1d178933b08d8c461645a639e8a5ffea15188c;p=thirdparty%2Fhaproxy.git CLEANUP: vars: make the error message clearer on missing arguments for set-var The error message after "http-response set-var" isn't very clear: [ALERT] 070/115043 (30526) : parsing [/dev/stdin:2] : error detected in proxy 'f' while parsing 'http-response set-var' rule : invalid variable 'set-var'. Expects 'set-var()' or 'unset-var()'. Let's change it to this instead: [ALERT] 070/115608 (30799) : parsing [/dev/stdin:2] : error detected in proxy 'f' while parsing 'http-response set-var' rule : invalid or incomplete action 'set-var'. Expects 'set-var()' or 'unset-var()'. With a wrong action name, it also works better (it's handled as a prefix due to the opening parenthesis): [ALERT] 070/115608 (30799) : parsing [/dev/stdin:2] : error detected in proxy 'f' while parsing 'http-response set-varxxx' rule : invalid or incomplete action 'set-varxxx'. Expects 'set-var()' or 'unset-var()'. --- diff --git a/src/vars.c b/src/vars.c index 65930c984e..3390d240cb 100644 --- a/src/vars.c +++ b/src/vars.c @@ -737,7 +737,7 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy } if (*var_name != '(') { - memprintf(err, "invalid variable '%s'. Expects 'set-var()' or 'unset-var()'", + memprintf(err, "invalid or incomplete action '%s'. Expects 'set-var()' or 'unset-var()'", args[*arg-1]); return ACT_RET_PRS_ERR; } @@ -745,7 +745,7 @@ static enum act_parse_ret parse_store(const char **args, int *arg, struct proxy var_len = strlen(var_name); var_len--; /* remove the ')' */ if (var_name[var_len] != ')') { - memprintf(err, "invalid variable '%s'. Expects 'set-var()' or 'unset-var()'", + memprintf(err, "incomplete expression after action '%s'. Expects 'set-var()' or 'unset-var()'", args[*arg-1]); return ACT_RET_PRS_ERR; }