Skip to content

Commit

Permalink
Merge pull request #170 from Aiven-Open/teakay-drop-none-tags
Browse files Browse the repository at this point in the history
senders: check tags for None keys/values
  • Loading branch information
giacomo-alzetta-aiven authored May 27, 2024
2 parents e354806 + 822f12b commit 9803f9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions journalpump/senders/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def make_tags(self, tags: Optional[Dict[str, str]] = None) -> Dict[str, str]:
output = self._tags.copy()
if tags:
for tag_name, tag_value in tags.items():
sanitized_name = self.unsafe_tag_name_chars.sub("_", tag_name).strip("_")
sanitized_value = self.unsafe_tag_value_chars.sub("_", tag_value).strip("_")
output[sanitized_name] = sanitized_value
if tag_name is not None and tag_value is not None:
sanitized_name = self.unsafe_tag_name_chars.sub("_", tag_name).strip("_")
sanitized_value = self.unsafe_tag_value_chars.sub("_", tag_value).strip("_")
output[sanitized_name] = sanitized_value
return output

def replace_tags(self, tags):
Expand Down
1 change: 1 addition & 0 deletions test/unit/senders/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"input_tags,expected_output_tags",
[
({"foo": "bar"}, {"foo": "bar"}),
({"foo": "bar", "bar": None, None: "baz"}, {"foo": "bar"}),
({"foo|wow,": "super!cool"}, {"foo_wow": "super!cool"}),
({"host": "localhost:1234"}, {"host": "localhost_1234"}),
({"base64": "YmFzZTY0Cg=="}, {"base64": "YmFzZTY0Cg"}),
Expand Down

0 comments on commit 9803f9c

Please sign in to comment.