From: Amaury Denoyelle Date: Fri, 31 Jul 2026 12:09:28 +0000 (+0200) Subject: MINOR: errors: further improve parsing error for server-template X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a91fe28291f20362e9ef894227fd9d987a35a4b;p=thirdparty%2Fhaproxy.git MINOR: errors: further improve parsing error for server-template The following patch improved error messages for server-template lines. This properly used instead of the 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 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 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. --- diff --git a/src/errors.c b/src/errors.c index 229218e32..9c34095c0 100644 --- a/src/errors.c +++ b/src/errors.c @@ -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;