Description
Deployment Type
Self-hosted
NetBox Version
v4.3.2
Python Version
3.11
Steps to Reproduce
-
Launch the NetBox shell:
python3 manage.py nbshell
-
Run the following:
from ipam.models import IPAddress from ipam.filtersets import IPAddressFilterSet qs = IPAddress.objects.all() filterset = IPAddressFilterSet() # Intentionally passing `None` as the `vrf` parameter result = filterset.filter_present_in_vrf(qs, 'present_in_vrf', None) print(result)
-
Observe the result when
vrf
isNone
.
Expected Behavior
When vrf
is None
, the method should return an empty queryset like:
<RestrictedQuerySet []>
Observed Behavior
The method instead returns a method reference:
<bound method QuerySet.none of <RestrictedQuerySet [...]>>
This happens because queryset.none
is returned without being called - i.e., it's missing parentheses. This causes unexpected behavior when the return value is used downstream, potentially leading to runtime issues or incorrect query evaluation.
netbox/netbox/ipam/filtersets.py
Lines 449 to 456 in 2680f85
netbox/netbox/ipam/filtersets.py
Lines 730 to 736 in 2680f85