Custom fields of type 'object' don't work with 'empty' filter expression #11447

Closed
opened 2025-12-29 21:45:20 +01:00 by adam · 4 comments
Owner

Originally created by @llamafilm on GitHub (Aug 2, 2025).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.3.2

Python Version

3.12

Steps to Reproduce

  1. Create a custom field called 'location_served' with type 'object (location)' and filter logic 'exact' and object types 'device'. (We use this when a device serves a room other than where it's physically located, for example an AV Closet next to a screening room.)
  2. Add some values to this custom field on a few devices.
  3. Try to filter /dcim/devices/?cf_location_served__empty=true

Expected Behavior

Since the custom field stores a numeric value, representing the ID of the linked object, it should respect all the numeric lookup expressions. Some expressions do work correctly, for example /dcim/devices/?cf_location_served__gt=18600.

Observed Behavior

It returns all objects, as if the filter were not present.

Originally created by @llamafilm on GitHub (Aug 2, 2025). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.3.2 ### Python Version 3.12 ### Steps to Reproduce 1. Create a custom field called 'location_served' with type 'object (location)' and filter logic 'exact' and object types 'device'. (We use this when a device serves a room other than where it's physically located, for example an AV Closet next to a screening room.) 2. Add some values to this custom field on a few devices. 3. Try to filter `/dcim/devices/?cf_location_served__empty=true` ### Expected Behavior Since the custom field stores a numeric value, representing the ID of the linked object, it should respect all the numeric lookup expressions. Some expressions do work correctly, for example `/dcim/devices/?cf_location_served__gt=18600`. ### Observed Behavior It returns all objects, as if the filter were not present.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:45:20 +01:00
adam closed this issue 2025-12-29 21:45:20 +01:00
Author
Owner

@llamafilm commented on GitHub (Aug 2, 2025):

This same bug also applies to custom fields of type 'integer'.

@llamafilm commented on GitHub (Aug 2, 2025): This same bug also applies to custom fields of type 'integer'.
Author
Owner

@jnovinger commented on GitHub (Aug 4, 2025):

This appears to be a legitimate bug where the __empty and __isnull lookup expressions don't work correctly for object-type (or integer) custom fields. We'll need to verify that custom fields were intended to support the documented lookup expressions implementation gap.

In the future, please ensure your report contains complete and accurate reproduction details, including exact field names and correct syntax, as this is crucial for efficient triage.

@jnovinger commented on GitHub (Aug 4, 2025): This appears to be a legitimate bug where the `__empty` and `__isnull` lookup expressions don't work correctly for object-type (or integer) custom fields. We'll need to verify that custom fields were intended to support the documented lookup expressions implementation gap. In the future, please ensure your report contains complete and accurate reproduction details, including exact field names and correct syntax, as this is crucial for efficient triage.
Author
Owner

@llamafilm commented on GitHub (Aug 6, 2025):

Thanks, I've added some details to the original post.

@llamafilm commented on GitHub (Aug 6, 2025): Thanks, I've added some details to the original post.
Author
Owner

@jeremystretch commented on GitHub (Aug 7, 2025):

Related to (and possibly blocked by) FR #18256

@jeremystretch commented on GitHub (Aug 7, 2025): Related to (and possibly blocked by) FR #18256
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11447