diff --git a/tests/light/functional_tests/filterx/test_filterx.py b/tests/light/functional_tests/filterx/test_filterx.py index 9908cd9fb..3ee1f51ca 100644 --- a/tests/light/functional_tests/filterx/test_filterx.py +++ b/tests/light/functional_tests/filterx/test_filterx.py @@ -2497,3 +2497,33 @@ def test_proper_generation_counter(config, syslog_ng): assert "processed" in file_true.get_stats() assert file_true.get_stats()["processed"] == 1 assert file_true.read_log() == '{"from_nvtable":"almafa","from_a_macro":"2000-01-01T00:00:00+01:00","unset_then_set":"kortefa"}\n' + + +def test_set_fields(config, syslog_ng): + (file_true, file_false) = create_config( + config, r""" + $MSG = { + "foo": "foo_exists", + "bar": "bar_exists", + }; + set_fields( + $MSG, + overrides={ + "foo": [invalid_expr, "foo_override"], + "baz": "baz_override", + "almafa": [invalid_expr_1, invalid_expr_2], # Should not have any effect, as there is no valid expr here. + }, + defaults={ + "foo": [invalid_expr, "foo_default"], # Should not have any effect, "foo" is handled by overrides. + "bar": "bar_default", # Should not have any effect, "bar" already has value in the dict. + "almafa": "almafa_default", + "kortefa": [invalid_expr_1, invalid_expr_2], # Should not have any effect, as there is no valid expr here. + } + ); + """, + ) + syslog_ng.start(config) + + assert file_true.get_stats()["processed"] == 1 + assert "processed" not in file_false.get_stats() + assert file_true.read_log() == '{"foo":"foo_override","bar":"bar_exists","baz":"baz_override","almafa":"almafa_default"}\n'