]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: errors: further improve parsing error for server-template
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 31 Jul 2026 12:09:28 +0000 (14:09 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 3 Aug 2026 09:11:19 +0000 (11:11 +0200)
The following patch improved error messages for server-template lines.
This properly used <tmpl_info.prefix> instead of the <id> field for
them, which prevents to display an empty string.

  94024a60dc197b26a13751a6a0eaa3071f023cfa
  MINOR: server: improve parsing error for server-template

This patch relied on server-template instance detection by checking if
<id> field is NULL. However, this is not appropriate once a
server-template has its ID assigned during _srv_parse_tmpl_init(). The
expanded name is displayed, which can be a misleading information as
this is not present directly in the configuration.

This patch fixes this by now detecting a server-template by checking if
its <tmpl_info.prefix> is non NULL. Thus, a server-template remains
detected as such even after its ID has been generating. Its template
name is used on error messages instead of the expanded prefix.

src/errors.c

index 229218e32a0642ff25d704e96e0043e441cfec1c..9c34095c05f1e462aaaeed805263f4362665d3c8 100644 (file)
@@ -222,10 +222,10 @@ static void generate_usermsgs_ctx_str(void)
                switch (obj_type(ctx->obj)) {
                case OBJ_TYPE_SERVER:
                        srv = __objt_server(ctx->obj);
-                       srv_id = srv->id ? srv->id : srv->tmpl_info.prefix;
+                       srv_id = srv->tmpl_info.prefix ? srv->tmpl_info.prefix : srv->id;
                        ret = snprintf(b_tail(&ctx->str), b_room(&ctx->str),
                                       "'%s %s/%s' : ",
-                                      srv->id ? "server" : "server-template",
+                                      srv->tmpl_info.prefix ? "server-template" : "server",
                                       srv->proxy->id, srv_id);
                        b_add(&ctx->str, MIN(ret, b_room(&ctx->str)));
                        break;