Fix Horizon crash on a patch installation
When a patch installation is triggered on a locked host via Horizon, it crashes redirecting to an error screen. The normal behaviour seen using the CLI is just an error message saying that the host is unknown because of being locked. Horizon should show this error message instead of crashing. The root cause is an issue during raising the ValueError expection, because of an 'AttributeError' exception raised on the 'split_message' function. This commit improves the robustness of the 'split_message' function by handling the 'AttributeError' exception. It ensures that the function returns a list with a single element containing 'value' when splitting is not possible, thereby preventing 'AttributeError' issues. Closes-Bug: 2040495 Test Plan: PASS: Build the 'horizon' package that will generate the python3-django-horizon deb package. Install it on a system and verify the changes are applied correctly. PASS: Build iso with these changes and perform a fresh install. Verify the changes are applied correctly. PASS: Execute test scenarios to raise a 'ValueError' in various situation. Verify that the exception is correctly raised, and the error message is displayed. Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com> Change-Id: Ib0cc834ee67e29c7cc486060d1b42be5a928bc49
This commit is contained in:
parent
ac9d905754
commit
2de0fdf14a
|
@ -0,0 +1,33 @@
|
|||
From be4910f7477913f7543aede63c435e5f4ef14c38 Mon Sep 17 00:00:00 2001
|
||||
From: Enzo Candotti <enzo.candotti@windriver.com>
|
||||
Date: Mon, 23 Oct 2023 14:44:26 -0300
|
||||
Subject: [PATCH] Prevent AttributeError on split_message function
|
||||
|
||||
This commit improves the robustness of the 'split_message' function
|
||||
by handling the 'AttributeError' exception. It ensures that the
|
||||
function returns a list with a single element containing 'value' when
|
||||
splitting is not possible, thereby preventing 'ValueError' issues.
|
||||
|
||||
Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com>
|
||||
---
|
||||
horizon/templatetags/splitfilter.py | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/horizon/templatetags/splitfilter.py b/horizon/templatetags/splitfilter.py
|
||||
index 7d5d497c7..1a598d373 100644
|
||||
--- a/horizon/templatetags/splitfilter.py
|
||||
+++ b/horizon/templatetags/splitfilter.py
|
||||
@@ -19,4 +19,8 @@ register = template.Library()
|
||||
|
||||
@register.filter(name='split_message')
|
||||
def split_message(value):
|
||||
- return value.split(exceptions.SEPERATOR)
|
||||
+ try:
|
||||
+ return value.split(exceptions.SEPERATOR)
|
||||
+ except AttributeError:
|
||||
+ # If it cannot be split, return a list with a single element containing 'value'.
|
||||
+ return [value]
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
0001-Use-policy_rules-for-user-role-assignment-and-group-tabs.patch
|
||||
0002-Fix-incomplete-pop-up-message-on-delete-Action.patch
|
||||
0003-List-default-Address-pools-row-actions-as-disabled.patch
|
||||
0004-Prevent-AttributeError-on-split_message-function.patch
|
||||
|
|
Loading…
Reference in New Issue