From cdbb3827fe8c8c16f9dc0cf82ebc4589b185f271 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sat, 13 May 2023 02:19:24 +0530 Subject: [PATCH 1/3] 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 c6744e524bd..689479da14d 100644 --- a/netbox/extras/conditions.py +++ b/netbox/extras/conditions.py @@ -65,8 +65,14 @@ def eval(self, data): """ Evaluate the provided data to determine whether it matches the condition. """ + def _get(obj, key): + if isinstance(obj, list): + return [i.get(key) for i in obj] + + return obj.get(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 From ef765d3a5765247412eff3977d6fdd2f43b074b8 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sat, 13 May 2023 02:31:40 +0530 Subject: [PATCH 2/3] fixes incorrectly handled type error when list of objects is found in data #9876 --- netbox/extras/conditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/extras/conditions.py b/netbox/extras/conditions.py index 689479da14d..1c001f7d54f 100644 --- a/netbox/extras/conditions.py +++ b/netbox/extras/conditions.py @@ -69,7 +69,7 @@ def _get(obj, key): if isinstance(obj, list): return [i.get(key) for i in obj] - return obj.get(key) + return dict.get(obj, key) try: value = functools.reduce(_get, self.attr.split('.'), data) From 239be333032d03c27ee845e96db03d71842421d2 Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sat, 13 May 2023 02:44:50 +0530 Subject: [PATCH 3/3] fixes incorrectly handled type error when list of objects is found in data #9876 --- netbox/extras/conditions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/extras/conditions.py b/netbox/extras/conditions.py index 1c001f7d54f..db054149efc 100644 --- a/netbox/extras/conditions.py +++ b/netbox/extras/conditions.py @@ -67,7 +67,7 @@ def eval(self, data): """ def _get(obj, key): if isinstance(obj, list): - return [i.get(key) for i in obj] + return [dict.get(i, key) for i in obj] return dict.get(obj, key)