From a6fa40ad870ea5302f4710dd29ce8dfef903e352 Mon Sep 17 00:00:00 2001 From: Sven Panne Date: Wed, 11 Sep 2024 16:00:25 +0200 Subject: [PATCH] 16123 FIX Use the original message text for rewriting the comment field 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 --- .werks/16123.md | 19 +++++++++++++++++++ cmk/ec/main.py | 4 +--- cmk/gui/mkeventd/wato.py | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 .werks/16123.md diff --git a/.werks/16123.md b/.werks/16123.md new file mode 100644 index 00000000000..280b8c425dd --- /dev/null +++ b/.werks/16123.md @@ -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. diff --git a/cmk/ec/main.py b/cmk/ec/main.py index 045c1ae6ff8..b3596aebb32 100644 --- a/cmk/ec/main.py +++ b/cmk/ec/main.py @@ -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: diff --git a/cmk/gui/mkeventd/wato.py b/cmk/gui/mkeventd/wato.py index 2ede43a1cce..c13fd7fd8e8 100644 --- a/cmk/gui/mkeventd/wato.py +++ b/cmk/gui/mkeventd/wato.py @@ -1354,7 +1354,7 @@ def vs_mkeventd_rule(customer: str | None = None) -> Dictionary: "etc. matching group." ) + _( - "The placeholder \\0 will be replaced by the original text of this field. " + "The placeholder \\0 will be replaced by the original message text. " "This allows you to add new information at the beginning or at the end." ), size=64,