Prevent ValueError 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. Test Plan: WIP Closes-Bug: WIP Signed-off-by: Enzo Candotti <enzo.candotti@windriver.com> Change-Id: Ib0cc834ee67e29c7cc486060d1b42be5a928bc49
This commit is contained in:
parent
ac9d905754
commit
56d881c96a
|
@ -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 ValueError 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.SEPARATOR)
|
||||
+ 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-ValueError-on-split_message-function.patch
|
||||
|
|
Loading…
Reference in New Issue