BUG/MINOR: log: Fix error message when using unavailable fetch in logfmt

The following configuration:

    defaults
    	unique-id-format TEST-%[srv_name]

    frontend fe_http
    	mode http

    	bind :::8080 v4v6

Emitted the following error:

    [ALERT]    (219835) : Parsing [./patch.cfg:2]: failed to parse unique-id : sample fetch <srv_name]> may not be reliably used here because it needs 'server' which is not available here.

The `]` in the name of the sample fetch should not be there.

This bug exists since at least HAProxy 2.4, which is the oldest supported
version. The fix should be backported there.

Reviewed-by: Volker Dusch <github@wallbash.com>
This commit is contained in:
Tim Duesterhus 2026-04-03 23:28:56 +02:00 committed by Willy Tarreau
parent 34c9ded340
commit 34c17608e7

View File

@ -671,13 +671,13 @@ static int add_sample_to_logformat_list(char *text, char *name, int name_len, in
if (!(expr->fetch->val & cap)) {
memprintf(err, "sample fetch <%s> may not be reliably used here because it needs '%s' which is not available here",
text, sample_src_names(expr->fetch->use));
expr->fetch->kw, sample_src_names(expr->fetch->use));
goto error_free;
}
if ((options & LOG_OPT_HTTP) && (expr->fetch->use & (SMP_USE_L6REQ|SMP_USE_L6RES))) {
ha_warning("parsing [%s:%d] : L6 sample fetch <%s> ignored in HTTP log-format string.\n",
lf_expr->conf.file, lf_expr->conf.line, text);
lf_expr->conf.file, lf_expr->conf.line, expr->fetch->kw);
}
LIST_APPEND(list_format, &node->list);