diff --git a/netbox/extras/conditions.py b/netbox/extras/conditions.py index 5680be444..8dec541bd 100644 --- a/netbox/extras/conditions.py +++ b/netbox/extras/conditions.py @@ -59,6 +59,7 @@ class Condition: if op not in self.TYPES[type(value)]: raise ValueError(_("Invalid type for {op} operation: {value}").format(op=op, value=type(value))) + self.op = op self.attr = attr self.value = value self.eval_func = getattr(self, f'eval_{op}') @@ -79,7 +80,12 @@ class Condition: except TypeError: # Invalid key path 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: return not result