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
16.14k stars 2.58k forks source link

Dynamic choice fields using query parameters clear existing values #17160

Open sweston99 opened 2 months ago

sweston99 commented 2 months ago

Deployment Type

Self-hosted

NetBox Version

v4.0.8

Python Version

3.11

Steps to Reproduce

  1. Example is adding vlans to a tagged interface and selecting the vlans using the VLANGroup filter.
  2. Create a vlan group, e.g. "Test-VG" and add two vlans to the vlan group, e.g. vlan100 and vlan101
  3. Create a device switch, with ethernet interfaces.
  4. Enable and edit an ethernet interface on the device. Set 802.1Q mode to "Tagged", select "Test-VG" as the VLAN Group to filter, and add vlan100 as a Tagged VLAN to the interface and save.
  5. Edit the same ethernet interface on the device. vlan100 should show as an existing tagged vlan on the interface. Select "Test-VG" as the VLAN Group to filter; it immediately clears vlan100 as an existing vlan. If you don't re-add all of your existing vlans, it will clear them when you save it.

Expected Behavior

Selecting the Test-VG vlan group should not clear existing selections, existing selections should still be there.

Observed Behavior

Existing vlans were cleared. Note that this issue is not specific to this UI interface or VLANGroups or VLANs, rather it seems to be an issue with the dynamic choice fields.

arthanson commented 2 months ago

This is basically the same as #17105 - leaving this open as well as it needs to be tested when that is fixed.

zndrr commented 1 month ago

Hi Team, as an FYI, I have experienced this behaviour in custom scripts on v4.0.11; specifically with fields utilising query_params that reference other fields on the script form. Sorry, have yet to determine full scope of our issue. I know that one script is unusuable as configured.