Duplicate Responses in filterqueries #11813

Closed
opened 2025-12-29 21:50:11 +01:00 by adam · 3 comments
Owner

Originally created by @MrFoxTrot on GitHub (Nov 6, 2025).

Originally assigned to: @pheus on GitHub.

NetBox Edition

NetBox Community

NetBox Version

v4.4.5

Python Version

3.12

Steps to Reproduce

  1. Create Circuits ->Provider
  2. Create 2+ Circuits -> Provider Accounts assigned at Circuits ->Provider from first step
  3. Go to Circuits ->Provider and filter by created provider name

Expected Behavior

Query returns 1 object

Observed Behavior

Query returns 2+ objects with same id

Image
Originally created by @MrFoxTrot on GitHub (Nov 6, 2025). Originally assigned to: @pheus on GitHub. ### NetBox Edition NetBox Community ### NetBox Version v4.4.5 ### Python Version 3.12 ### Steps to Reproduce 1. Create Circuits ->Provider 2. Create 2+ Circuits -> Provider Accounts assigned at Circuits ->Provider from first step 3. Go to Circuits ->Provider and filter by created provider name ### Expected Behavior Query returns 1 object ### Observed Behavior Query returns 2+ objects with same id <img width="547" height="509" alt="Image" src="https://github.com/user-attachments/assets/7e65aa69-421b-4247-ac7f-bf0a12743bfd" />
adam added the type: bugstatus: acceptednetboxseverity: low labels 2025-12-29 21:50:11 +01:00
adam closed this issue 2025-12-29 21:50:11 +01:00
Author
Owner

@bctiemann commented on GitHub (Nov 6, 2025):

I'd be interested to know whether this behavior occurs in any similar search results, i.e. anything with a "count" column in this kind of relationship. I'm going to open this as "needs owner", but @MrFoxTrot if you are able could you please do a quick check for other similar areas where this might be occurring?

@bctiemann commented on GitHub (Nov 6, 2025): I'd be interested to know whether this behavior occurs in any similar search results, i.e. anything with a "count" column in this kind of relationship. I'm going to open this as "needs owner", but @MrFoxTrot if you are able could you please do a quick check for other similar areas where this might be occurring?
Author
Owner

@pheus commented on GitHub (Nov 6, 2025):

Thanks for the report! I dug into this and it doesn’t look like a common issue. The root cause is that ProviderFilterSet.search() is querying fields on the related ProviderAccount model in addition to the provider’s own name, description, and comments:

730d73042d/netbox/circuits/filtersets.py (L92-L93)

In NetBox, search() methods shouldn’t traverse related models.

I recommend removing the ProviderAccount lookups so the search is limited to the provider fields. If that sounds good, I’m happy to open a PR to address it.

@pheus commented on GitHub (Nov 6, 2025): Thanks for the report! I dug into this and it doesn’t look like a common issue. The root cause is that `ProviderFilterSet.search()` is querying fields on the related `ProviderAccount` model in addition to the provider’s own `name`, `description`, and `comments`: https://github.com/netbox-community/netbox/blob/730d73042d5ee34b31f16e2c978cb65718eb794e/netbox/circuits/filtersets.py#L92-L93 In NetBox, `search()` methods shouldn’t traverse related models. I recommend removing the `ProviderAccount` lookups so the search is limited to the provider fields. If that sounds good, I’m happy to open a PR to address it.
Author
Owner

@bctiemann commented on GitHub (Nov 6, 2025):

@pheus That sounds right to me. Thanks!

@bctiemann commented on GitHub (Nov 6, 2025): @pheus That sounds right to me. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11813