diff --git a/include/haproxy/stats-t.h b/include/haproxy/stats-t.h index 07eaf6d50..ca2b78d03 100644 --- a/include/haproxy/stats-t.h +++ b/include/haproxy/stats-t.h @@ -355,7 +355,9 @@ enum info_field { /* Stats fields for CSV output. For any field added here, please add the text * representation in the stat_fields array. Please only append at the end, * before the ST_F_TOTAL_FIELDS entry, and never insert anything in the middle - * nor at the beginning. + * nor at the beginning.When adding an entry here, one must always add a + * corresponding one in stat_fields[] otherwise Lua's get_stats() will break, + * and "show stats" will show a null. */ enum stat_field { ST_F_PXNAME, diff --git a/reg-tests/webstats/missing-stats-fields.vtc b/reg-tests/webstats/missing-stats-fields.vtc new file mode 100644 index 000000000..c85855d5f --- /dev/null +++ b/reg-tests/webstats/missing-stats-fields.vtc @@ -0,0 +1,14 @@ +varnishtest "Verifies the absence of (null) in 'show stats' header" + +# This can happen if a new ST_F_xxx enum is added without updating +# stats_fields[]. + +feature ignore_unknown_macro + +haproxy h1 -conf { +} -start + +haproxy h1 -cli { + send "show stat" + expect !~ (null) +}