From 7cb302f9d796b19626dcca061bcb2c61a6b0d9c3 Mon Sep 17 00:00:00 2001 From: dtrai2 Date: Fri, 8 Nov 2024 14:51:43 +0100 Subject: [PATCH] fix template_replacer processor --- logprep/processor/template_replacer/processor.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/logprep/processor/template_replacer/processor.py b/logprep/processor/template_replacer/processor.py index 653e1e0cd..0597f2e33 100644 --- a/logprep/processor/template_replacer/processor.py +++ b/logprep/processor/template_replacer/processor.py @@ -114,16 +114,8 @@ def _perform_replacement(self, event: dict, replacement: str, rule: TemplateRepl If target value isn't None, then it exists and its parents must be dicts. Therefore, they wouldn't be replaced, and we can overwrite the existing target field. """ - if get_dotted_field_value(event, self._target_field) is None: - add_successful = add_field_to( - event, - self._target_field, - replacement, - ) - if not add_successful: - raise FieldExistsWarning(rule, event, [self._target_field]) - else: - add_field_to(event, self._target_field, replacement, overwrite_output_field=True) + overwrite = get_dotted_field_value(event, self._target_field) is not None + add_field_to(event, self._target_field, replacement, overwrite_output_field=overwrite) def setup(self): super().setup()