Skip to content

Commit 07a6af0

Browse files
authored
Merge pull request #462 from bshifter/fx-fix-pubsub
Fix filterx/pubsub message empty attributes
2 parents 5d15246 + 433e335 commit 07a6af0

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

modules/grpc/pubsub/filterx/object-pubsub-message.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ Message::set_attribute(const std::string &key, const std::string &value)
101101
{
102102
throw std::invalid_argument("Key cannot be empty");
103103
}
104-
if (value.empty())
105-
{
106-
throw std::invalid_argument("Value cannot be empty");
107-
}
108104
auto attributes = message.mutable_attributes();
109105
if (attributes)
110106
{

tests/light/functional_tests/filterx/test_filterx.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2634,13 +2634,15 @@ def test_pubsub_message(config, syslog_ng):
26342634
config, r"""
26352635
$MSG = json();
26362636
$MSG.msg = pubsub_message("my pubsub message", {"foo":"bar"});
2637+
$MSG.empty = pubsub_message("empty attribute value", {"empty":""});
26372638
""",
26382639
)
26392640
syslog_ng.start(config)
26402641

26412642
assert file_true.get_stats()["processed"] == 1
26422643
assert "processed" not in file_false.get_stats()
26432644
exp = (
2644-
r"""{"msg":{"data":"my pubsub message","attributes":{"foo":"bar"}}}""" + "\n"
2645+
r"""{"msg":{"data":"my pubsub message","attributes":{"foo":"bar"}},"""
2646+
""""empty":{"data":"empty attribute value","attributes":{"empty":""}}}""" + "\n"
26452647
)
26462648
assert file_true.read_log() == exp

0 commit comments

Comments
 (0)