]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cfgparse-global: add explicit error messages in cfg_parse_global_env_opts
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 28 Apr 2025 21:00:17 +0000 (23:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 May 2025 13:37:45 +0000 (15:37 +0200)
When env variable name or value are not provided for setenv/presetenv it's not
clear from the old error message shown at stderr, what exactly is missed. User
needs to search in it's configuration.

Let's add more explicit error messages about these inconsistencies.

No need to be backported.

src/cfgparse-global.c

index 370da3e943f9ba3575eac71cbd301eae27788861..2221ea2b956453d4b5b010b1e005699b081f87c3 100644 (file)
@@ -1472,10 +1472,15 @@ static int cfg_parse_global_env_opts(char **args, int section_type,
        if (strcmp(args[0], "setenv") == 0 || strcmp(args[0], "presetenv") == 0) {
                if (too_many_args(2, args, err, NULL))
                        return -1;
+               if (*(args[1]) == 0) {
+                       memprintf(err, "'%s' expects environment variable name.\n.",
+                                 args[0]);
+                       return -1;
+               }
 
                if (*(args[2]) == 0) {
-                       memprintf(err, "'%s' expects an env variable name and a value.\n.",
-                                 args[0]);
+                       memprintf(err, "'%s' expects environment variable value for '%s'.\n.",
+                                 args[0], args[1]);
                        return -1;
                }