Skip to content

Commit

Permalink
16123 FIX Use the original message text for rewriting the comment field
Browse files Browse the repository at this point in the history
Werk 16534 made the rewriting of the comment field use the comment field
itself as the basis. For this field, it doesn't really make sense, because
rewriting is the only way to fill that field, so e.g. \0 was always empty.

With this change, we revert to the old behaviour where all match groups
refer to the original message text.

Change-Id: I761db0445b485da62c30656b42bcc65ed30d1151
  • Loading branch information
spt29 committed Sep 17, 2024
1 parent 3625534 commit a6fa40a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .werks/16123.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[//]: # (werk v2)
# Use the original message text for rewriting the comment field

key | value
---------- | ---
date | 2024-09-11T13:54:07+00:00
version | 2.3.0p17
class | fix
edition | cre
component | ec
level | 1
compatible | yes

Werk 16534 made the rewriting of the comment field use the comment field
itself as the basis. For this field, it doesn't really make sense, because
rewriting is the only way to fill that field, so e.g. \0 was always empty.

With this change, we revert to the old behaviour where all match groups
refer to the original message text.
4 changes: 1 addition & 3 deletions cmk/ec/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,7 @@ def rewrite_event( # pylint: disable=too-many-branches
event["first"] = event["time"]
event["last"] = event["time"]
if "set_comment" in rule:
event["comment"] = replace_groups(
rule["set_comment"], event.get("comment", ""), match_groups
)
event["comment"] = replace_groups(rule["set_comment"], event["text"], match_groups)
if "set_text" in rule:
event["text"] = replace_groups(rule["set_text"], event["text"], match_groups)
if "set_host" in rule:
Expand Down
2 changes: 1 addition & 1 deletion cmk/gui/mkeventd/wato.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ def vs_mkeventd_rule(customer: str | None = None) -> Dictionary:
"etc. matching group."
)
+ _(
"The placeholder <tt>\\0</tt> will be replaced by the original text of this field. "
"The placeholder <tt>\\0</tt> will be replaced by the original message text. "
"This allows you to add new information at the beginning or at the end."
),
size=64,
Expand Down

0 comments on commit a6fa40a

Please sign in to comment.