Lookup expression on custom field returning incorrect record set #5812

Closed
opened 2025-12-29 19:33:01 +01:00 by adam · 2 comments
Owner

Originally created by @sol1james on GitHub (Dec 21, 2021).

NetBox version

3.1.0

Python version

3.7

Steps to Reproduce

  1. Our system has a custom field (integer) for tenants called droids_id. One record has a droids_id of 1601 - I believe all the remaining records (there are 102 in total) have IDs greater than this
  2. Querying for droids_id 1601 returns no records
    http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id=1601&cf_droids_url=
  3. Querying for droids_id > 1601 returns 98 records, including the one with id=1601
    http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__gt=1601
  4. Querying for droids_id > 2000 returns 98 records so it looks like some filtering is happening
    http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__gt=2000
  5. Querying for droids_id < 2000 returns nothing
    http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__lt=2000
    also tried <= with same result:
    http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__lte=2000

Expected Behavior

The query for list item 2 should return 1 record with droids_id 1601
Query 3 should return 101 records, excluding droids_id 1601
Query 4 should return all records with droids_id > 2000 and query 5 should return all records with droids_id < 2000

Observed Behavior

See "Steps to reproduce"

Originally created by @sol1james on GitHub (Dec 21, 2021). ### NetBox version 3.1.0 ### Python version 3.7 ### Steps to Reproduce 1. Our system has a custom field (integer) for tenants called droids_id. One record has a droids_id of 1601 - I believe all the remaining records (there are 102 in total) have IDs greater than this 2. Querying for droids_id 1601 returns no records http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id=1601&cf_droids_url= 3. Querying for droids_id > 1601 returns 98 records, including the one with id=1601 http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__gt=1601 4. Querying for droids_id > 2000 returns 98 records so it looks like some filtering is happening http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__gt=2000 5. Querying for droids_id < 2000 returns nothing http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__lt=2000 also tried <= with same result: http://netbox.hq.sol1.net/tenancy/tenants/?q=&cf_droids_id__lte=2000 ### Expected Behavior The query for list item 2 should return 1 record with droids_id 1601 Query 3 should return 101 records, excluding droids_id 1601 Query 4 should return all records with droids_id > 2000 and query 5 should return all records with droids_id < 2000 ### Observed Behavior See "Steps to reproduce"
adam added the type: bug label 2025-12-29 19:33:01 +01:00
adam closed this issue 2025-12-29 19:33:02 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 21, 2021):

I'm not able to replicate this on v3.1.2. Looks like you may be running into #7690, which was fixed in v3.1.1. Please upgrade your NetBox installation and try your tests again.

@jeremystretch commented on GitHub (Dec 21, 2021): I'm not able to replicate this on v3.1.2. Looks like you may be running into #7690, which was fixed in v3.1.1. Please upgrade your NetBox installation and try your tests again.
Author
Owner

@jeremystretch commented on GitHub (Dec 21, 2021):

I'm going to close this out as I'm almost certain it's already been resolved, but please report back if upgrading does not fix the issue for you.

@jeremystretch commented on GitHub (Dec 21, 2021): I'm going to close this out as I'm almost certain it's already been resolved, but please report back if upgrading does not fix the issue for you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5812