netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.91k stars 2.55k forks source link

Filtering device components per device role fails #16536

Closed Alef-Burzmali closed 2 months ago

Alef-Burzmali commented 3 months ago

Deployment Type

Self-hosted

NetBox Version

v4.0.5

Python Version

3.10

Steps to Reproduce

  1. Create a device role "role_1" and "role_2"
  2. Create a device "device_1" with role "role_1" and a device "device_2" with "role_2"
  3. Create an interface on device_1 and another on device_2
  4. In the Interface list, use the Filters tab to filter on device role role_1

Expected Behavior

Only interfaces of devices with role_1 are displayed.

Observed Behavior

All the interfaces are displayed, the list is not filtered.

Alef-Burzmali commented 3 months ago

The cause seems to be that DeviceComponentFilterForm still uses field device_role_id while DeviceComponentFilterSet has been updated by #15099 to expect role_id parameter. If the URL query parameter is changed to role_id , then the list is filtered as expected.

https://github.com/netbox-community/netbox/blob/83da49cfa3950f5acb1e48bb5aa9943999a782cf/netbox/dcim/forms/filtersets.py#L114-L118

I can submit a PR, if assigned.

jeremystretch commented 3 months ago

Thanks @Alef-Burzmali, I've assigned this to you.