Module: check_mk
Branch: master
Commit: 4eb42c3f88e9f90faf7f88198ac56896d5568a38
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4eb42c3f88e9f9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 21 13:53:30 2016 +0100
3302 FIX Improved error handling when trying to edit a not existing rule
---
.werks/3302 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 14 +++++++++++---
3 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/.werks/3302 b/.werks/3302
new file mode 100644
index 0000000..f851793
--- /dev/null
+++ b/.werks/3302
@@ -0,0 +1,10 @@
+Title: Improved error handling when trying to edit a not existing rule
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1458564780
+
+
diff --git a/ChangeLog b/ChangeLog
index 1407d2b..31e8866 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -159,6 +159,7 @@
* 3296 FIX: Hiding pending changes related buttons after discarding changes
* 3314 FIX: Correctly add custom user attribute values after change in attribute
declaration...
* 3316 FIX: Fix validation of empty or missing file uploads (such as in Bulk host
import)
+ * 3302 FIX: Improved error handling when trying to edit a not existing rule
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index ecd7132..02b4dcc 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -12780,10 +12780,18 @@ def mode_edit_rule(phase, new = False):
if phase != "action":
html.message(_("Cannot create rule: %s") % e)
return
- rulenr = len(rules)
+ rulenr = len(rules)
else:
- rulenr = int(html.var("rulenr"))
- rule = rules[rulenr]
+ rulenr = int(html.var("rulenr"))
+ try:
+ rule = rules[rulenr]
+ except IndexError:
+ if phase == "action":
+ raise MKUserError("rulenr", _("You are trying to edit a
rule which does not exist "
+ "anymore."))
+ else:
+ html.show_error(_("You are trying to edit a rule which does not
exist anymore."))
+ return
valuespec = rulespec.get("valuespec")
value, tag_specs, host_list, item_list, rule_options = parse_rule(rulespec, rule)