From: Aki Tuomi Date: Thu, 6 Jul 2023 07:49:48 +0000 (+0300) Subject: stats: Do not break submetrics is field is missing X-Git-Tag: 2.4.0~2640 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd1be809c8fd556a2db1080c20ade3edf888bc1f;p=thirdparty%2Fdovecot%2Fcore.git stats: Do not break submetrics is field is missing If the field does not exist, emulate it as empty field, and continue submetrics. --- diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index 301a0e5fc4..96dca8be2b 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -642,10 +642,17 @@ stats_metric_group_by(struct metric *metric, struct event *event, pool_t pool) event_find_field_recursive(event, metric->group_by[0].field); /* ignore missing field */ - if (field == NULL) - return; - - if (field->value_type != EVENT_FIELD_VALUE_TYPE_STRLIST) + if (field == NULL) { + const struct event_field empty_event_field = { + .value_type = EVENT_FIELD_VALUE_TYPE_STR, + .key = metric->group_by[0].field, + .value = { + .str = "", + }, + }; + stats_metric_group_by_field(metric, event, &empty_event_field, + pool); + } else if (field->value_type != EVENT_FIELD_VALUE_TYPE_STRLIST) stats_metric_group_by_field(metric, event, field, pool); else { /* Handle each string in strlist separately. The strlist needs