Query too permissive in GUI filter for sites #5638

Closed
opened 2025-12-29 19:30:25 +01:00 by adam · 6 comments
Owner

Originally created by @jmcguir on GitHub (Nov 9, 2021).

NetBox version

v3.0.8

Python version

3.8

Steps to Reproduce

  1. Double check in configuration.py that Paginate_Count is 50 or less.
  2. Create 51 sites named from 1 - 51, with a Physical Address that has a zip code with the numbers '51' in them.
  3. Go to the /dcim/devices/ endpoint in the GUI.
  4. Click on the filters tab and search for '51' in the sites filter

Expected Behavior

I expect that site 51 should show up in the api-select widget and that I can click it to filter for only devices in site 51.

I further expect that it would only query for sites with the string '51' in the name or slug from the sites endpoint since it is filtering on slug/name (I can't exactly tell where in the code) in this widget anyways.

Observed Behavior

Instead no results are found. This happens because it pulls the first 50 sites and since all the sites have the string "51" in the physical address it never actually pulls up the site with the name 51.

I talked about this in discussion https://github.com/netbox-community/netbox/discussions/7663 but at that point I didn't understand the issue enough to write up a bug report.

Thanks so much for your time.

Originally created by @jmcguir on GitHub (Nov 9, 2021). ### NetBox version v3.0.8 ### Python version 3.8 ### Steps to Reproduce 1. Double check in configuration.py that `Paginate_Count` is 50 or less. 2. Create 51 sites named from 1 - 51, with a Physical Address that has a zip code with the numbers '51' in them. 3. Go to the /dcim/devices/ endpoint in the GUI. 4. Click on the filters tab and search for '51' in the sites filter ### Expected Behavior I expect that site 51 should show up in the api-select widget and that I can click it to filter for only devices in site 51. I further expect that it would only query for sites with the string '51' in the name or slug from the sites endpoint since it is filtering on slug/name (I can't exactly tell where in the code) in this widget anyways. ### Observed Behavior Instead no results are found. This happens because it pulls the first 50 sites and since all the sites have the string "51" in the physical address it never actually pulls up the site with the name 51. I talked about this in discussion https://github.com/netbox-community/netbox/discussions/7663 but at that point I didn't understand the issue enough to write up a bug report. Thanks so much for your time.
adam added the type: bugstatus: under review labels 2025-12-29 19:30:25 +01:00
adam closed this issue 2025-12-29 19:30:25 +01:00
Author
Owner

@sdktr commented on GitHub (Nov 9, 2021):

What's the problem here? Can you retry with a filled template?

@sdktr commented on GitHub (Nov 9, 2021): What's the problem here? Can you retry with a filled template?
Author
Owner

@jeremystretch commented on GitHub (Nov 9, 2021):

I think I follow. When you type "51" into the filter field, it triggers a REST API call for /api/dcim/sites/?brief=true&q=51. The response includes fifty objects (the first fifty matching sites), however none of them are being populated in the widget.

Presumably, this is because we're filtering on the display text of the returned objects, which we shouldn't be. Normally, if at least one object was populated in the widget, scrolling to the end of the available choices would trigger successive pages to load. But that can't happen here, because we have no choices initially.

@thatmattlove any chance you can take a crack at this?

@jeremystretch commented on GitHub (Nov 9, 2021): I think I follow. When you type "51" into the filter field, it triggers a REST API call for `/api/dcim/sites/?brief=true&q=51`. The response includes fifty objects (the first fifty matching sites), however none of them are being populated in the widget. Presumably, this is because we're filtering on the display text of the returned objects, which we shouldn't be. Normally, if at least one object was populated in the widget, scrolling to the end of the available choices would trigger successive pages to load. But that can't happen here, because we have no choices initially. @thatmattlove any chance you can take a crack at this?
Author
Owner

@DanSheps commented on GitHub (Nov 9, 2021):

That looks to be the case @jeremystretch. I just confirmed this (I did it on the test instance if you are curious, you can type in "56" and it will not return any results).

I think the disconnect is from the filter in typescript to the filter in javascript. I don't know of any easy way to search all these objects though in typescript the same way we do with the filterset we have, unless we include a "searchable string" with the api request or define the fields to search in the serializer's "header"

@DanSheps commented on GitHub (Nov 9, 2021): That looks to be the case @jeremystretch. I just confirmed this (I did it on the test instance if you are curious, you can type in "56" and it will not return any results). I think the disconnect is from the filter in typescript to the filter in javascript. I don't know of any easy way to search all these objects though in typescript the same way we do with the filterset we have, unless we include a "searchable string" with the api request or define the fields to search in the serializer's "header"
Author
Owner

@jmcguir commented on GitHub (Nov 9, 2021):

Thanks for taking a look at this! Personally I'd like the fix to be that when you search, at least for sites, for it only to look at the slug and the name of the site. Like in our case typing in 85, because of our zip code will load like 100's of sites if it kept scrolling.

It strikes me that it's a bit too clever to type in parts of physical address to find sites that match that. I respect that as the first person to bring that up though my viewpoint is biased.

@jmcguir commented on GitHub (Nov 9, 2021): Thanks for taking a look at this! Personally I'd like the fix to be that when you search, at least for sites, for it only to look at the slug and the name of the site. Like in our case typing in 85, because of our zip code will load like 100's of sites if it kept scrolling. It strikes me that it's a bit too clever to type in parts of physical address to find sites that match that. I respect that as the first person to bring that up though my viewpoint is biased.
Author
Owner

@github-actions[bot] commented on GitHub (Jan 9, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Jan 9, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@DanSheps commented on GitHub (Jan 18, 2022):

Resolved by #8057

@DanSheps commented on GitHub (Jan 18, 2022): Resolved by #8057
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5638