Skip to content

Commit

Permalink
fix template_replacer processor
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrai2 committed Nov 8, 2024
1 parent 47f5727 commit 7cb302f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions logprep/processor/template_replacer/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7cb302f

Please sign in to comment.