34 lines
1.2 KiB
Diff
34 lines
1.2 KiB
Diff
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
|
|
|