mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
Fixes #19633. Handle case that was the reason of TypeError and raise exeption: "TypeError: argument of type 'NoneType' is not iterable" with lead to breaking all events in the same object_type.
This commit is contained in:
parent
2f9e1cee04
commit
8c8797599b
@ -59,6 +59,7 @@ class Condition:
|
|||||||
if op not in self.TYPES[type(value)]:
|
if op not in self.TYPES[type(value)]:
|
||||||
raise ValueError(_("Invalid type for {op} operation: {value}").format(op=op, value=type(value)))
|
raise ValueError(_("Invalid type for {op} operation: {value}").format(op=op, value=type(value)))
|
||||||
|
|
||||||
|
self.op = op
|
||||||
self.attr = attr
|
self.attr = attr
|
||||||
self.value = value
|
self.value = value
|
||||||
self.eval_func = getattr(self, f'eval_{op}')
|
self.eval_func = getattr(self, f'eval_{op}')
|
||||||
@ -79,7 +80,12 @@ class Condition:
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
# Invalid key path
|
# Invalid key path
|
||||||
value = None
|
value = None
|
||||||
result = self.eval_func(value)
|
if value is None:
|
||||||
|
# Hande comparison case when value is None.
|
||||||
|
if self.op in (self.GT, self.GTE, self.LT, self.LTE, self.IN, self.CONTAINS, self.REGEX):
|
||||||
|
result = False
|
||||||
|
else:
|
||||||
|
result = self.eval_func(value)
|
||||||
|
|
||||||
if self.negate:
|
if self.negate:
|
||||||
return not result
|
return not result
|
||||||
|
Loading…
Reference in New Issue
Block a user