From e7f689bc52d090428528af10f8b2f616838cc6da Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Thu, 1 Jun 2023 01:14:59 +0530 Subject: [PATCH] Fixes incorrectly handled type error when list of objects is found in data (#12593) * fixes incorrectly handled type error when list of objects is found in data #9876 * fixes incorrectly handled type error when list of objects is found in data #9876 * fixes incorrectly handled type error when list of objects is found in data #9876 --- netbox/extras/conditions.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/netbox/extras/conditions.py b/netbox/extras/conditions.py index c6744e524..db054149e 100644 --- a/netbox/extras/conditions.py +++ b/netbox/extras/conditions.py @@ -65,8 +65,14 @@ class Condition: """ Evaluate the provided data to determine whether it matches the condition. """ + def _get(obj, key): + if isinstance(obj, list): + return [dict.get(i, key) for i in obj] + + return dict.get(obj, key) + try: - value = functools.reduce(dict.get, self.attr.split('.'), data) + value = functools.reduce(_get, self.attr.split('.'), data) except TypeError: # Invalid key path value = None