Bulk update does not enforce model validation #914

Closed
opened 2025-12-29 16:26:56 +01:00 by adam · 1 comment
Owner

Originally created by @candlerb on GitHub (May 4, 2017).

Originally assigned to: @jeremystretch on GitHub.

Issue type: bug report

Python version: 2.7.12
NetBox version: 1.9.6

How to reproduce:

  • Create two sites (e.g. foo and bar)
  • Create some racks in foo and in bar
  • Create two new rack groups, one each in foo and bar, both called "Management"
  • Browse racks
  • Check box beside racks in site foo only, and then click "Edit Selected" to get bulk update page
  • The "Group" dropdown menu shows both Foo-Management and Bar-Management
  • Select Bar-Management and then Apply

Now, the data model is screwed. The racks in site Foo belong to a rack group in site Bar.

However, from the UI the problem isn't initially apparent:

  • Browse all racks, and those racks show "Foo" in the site column and "Management" in the group column
  • Click on one rack (goes to /dcim/racks/NNN/) and it shows site Foo, group Management
  • Click on the group name (goes to /dcim/racks/?site=foo&group=management) and things still look OK.

But if you look in the filter section in the RHS, under Rack Group, you'll see Foo (0) and Bar (2)

Suggested solutions:

  • At a low level, refuse to set a rack group on a rack if it would result in (rack.site) != (rack_group.site)
  • The bulk update page for Rack could minimise the choices offered
    • If no new Site has been selected, then only offer rack groups which are in the Site of the selected Racks
    • If the selected Racks span more than one Site, then don't offer any bulk update of rack groups unless you're also setting a new Site, except to set Rack Group to Null
    • Maybe drop the ability to bulk change the Site of Racks entirely, since that can lead to all sorts of other inconsistencies if there are devices already in the rack
  • Avoid slugs in hyperlinks, e.g. /dcim/racks/?site=foo&group=management should become /dcim/racks/?group_id=123. (This will be necessary anyway if slugs are removed, as proposed in the google group)

Note: there might be other cases where this occurs. For example: there is a link from Device to Site as well as Device to Rack and Rack to Site. The bulk update page for Device doesn't let you set either Rack or Site, so it's not an issue there; but changing the Site of a Rack could.

Originally created by @candlerb on GitHub (May 4, 2017). Originally assigned to: @jeremystretch on GitHub. ### Issue type: bug report **Python version:** 2.7.12 **NetBox version:** 1.9.6 How to reproduce: * Create two sites (e.g. foo and bar) * Create some racks in foo and in bar * Create two new rack groups, one each in foo and bar, both called "Management" * Browse racks * Check box beside racks in site foo only, and then click "Edit Selected" to get bulk update page * The "Group" dropdown menu shows both Foo-Management and Bar-Management * Select Bar-Management and then Apply Now, the data model is screwed. The racks in site Foo belong to a rack group in site Bar. However, from the UI the problem isn't initially apparent: * Browse all racks, and those racks show "Foo" in the site column and "Management" in the group column * Click on one rack (goes to `/dcim/racks/NNN/`) and it shows site Foo, group Management * Click on the group name (goes to `/dcim/racks/?site=foo&group=management`) and things still look OK. But if you look in the filter section in the RHS, under Rack Group, you'll see `Foo (0)` and `Bar (2)` Suggested solutions: * At a low level, refuse to set a rack group on a rack if it would result in (rack.site) != (rack_group.site) * The bulk update page for Rack could minimise the choices offered * If no new Site has been selected, then only offer rack groups which are in the Site of the selected Racks * If the selected Racks span more than one Site, then don't offer any bulk update of rack groups unless you're also setting a new Site, except to set Rack Group to Null * Maybe drop the ability to bulk change the Site of Racks entirely, since that can lead to all sorts of other inconsistencies if there are devices already in the rack * Avoid slugs in hyperlinks, e.g. `/dcim/racks/?site=foo&group=management` should become `/dcim/racks/?group_id=123`. (This will be necessary anyway if slugs are removed, as proposed in the google group) Note: there might be other cases where this occurs. For example: there is a link from Device to Site as well as Device to Rack and Rack to Site. The bulk update page for Device doesn't let you set either Rack or Site, so it's not an issue there; but changing the Site of a Rack could.
adam added the type: bug label 2025-12-29 16:26:56 +01:00
adam closed this issue 2025-12-29 16:26:56 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 20, 2017):

Resolved in b65d994

@jeremystretch commented on GitHub (Dec 20, 2017): Resolved in b65d994
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#914