Strange behavior when changing the parent location with [Bulk Edit] #7211

Closed
opened 2025-12-29 20:20:30 +01:00 by adam · 7 comments
Owner

Originally created by @mscpik on GitHub (Nov 9, 2022).

NetBox version

v3.3.8 (fresh installation)

Python version

3.10

Steps to Reproduce

I create locations in a hierarchical order with 3 layers.

Layer 1: buildings

Layer 2: floors

Layer 3: rooms

like this
image

I created child locations(rooms) with "Add Child Location" button and some of them on the wrong floor.
image

To correct this I edit (single edit) the location with the wrong floor and change the parent of this location object to the right one.
Here for locations "building A_room 0.01" and "building A_room 0.02" to change the parent to "building A - ground" with no problems.
image

But if I use "Bulk Edit" over the "Edit Selected" button(from a VM snapshot), here for locations "building A_room 0.01" and "building A_room 0.02", to change the parent to "building A - ground", I get this as result.
The hierarchical order of this locations is destroyed/mixed up.
image
location "building A - ground"
image
location "building A - room 0.01"
image

Expected Behavior

Move all selected locations with "bulk edit" to the correct parent location.

Observed Behavior

Rooms seems to be in more than one parent location and some location objects not moveable/editable any more, even if want to remove(Set Null) the parent in the location object, independent of the edit mode I used.
In some situations I also get an server error if I want to remove a parent of a location.
Like this location object
image
In edit location I removed the parent location and get this error message.
image
Complete error message:

<class 'django.db.utils.IntegrityError'>

new row for relation "dcim_location" violates check constraint "dcim_location_level_check"
DETAIL: Failing row contains (2022-11-17 14:15:01.236855+00, 2022-11-17 14:15:01.236905+00, {}, 30, building A - ground, building-a-ground, , 2, 23, 2, -1, 27, 1, null, active).

Python version: 3.10.6
NetBox version: 3.3.8

Originally created by @mscpik on GitHub (Nov 9, 2022). ### NetBox version v3.3.8 (fresh installation) ### Python version 3.10 ### Steps to Reproduce I create locations in a hierarchical order with 3 layers. Layer 1: buildings > Layer 2: floors > > Layer 3: rooms like this ![image](https://user-images.githubusercontent.com/114069964/202457015-d8b18b28-998c-4c85-97bc-5f72ee178e9c.png) I created child locations(rooms) with "Add Child Location" button and some of them on the wrong floor. ![image](https://user-images.githubusercontent.com/114069964/202458444-8a3c8963-9de7-4048-8bcd-0e70bb0e91d4.png) To correct this I edit (single edit) the location with the wrong floor and change the parent of this location object to the right one. Here for locations "building A_room 0.01" and "building A_room 0.02" to change the parent to "building A - ground" with no problems. ![image](https://user-images.githubusercontent.com/114069964/202505627-c347478d-c4b0-49b7-8c86-0102d8cd8a40.png) But if I use "Bulk Edit" over the "Edit Selected" button(from a VM snapshot), here for locations "building A_room 0.01" and "building A_room 0.02", to change the parent to "building A - ground", I get this as result. The hierarchical order of this locations is destroyed/mixed up. ![image](https://user-images.githubusercontent.com/114069964/202498980-19d2e53e-a42f-4e8a-b08c-37ff58d60256.png) location "building A - ground" ![image](https://user-images.githubusercontent.com/114069964/202500688-9e42cf88-2460-44e2-9996-50ce1e40185a.png) location "building A - room 0.01" ![image](https://user-images.githubusercontent.com/114069964/202502241-1a58f279-0044-43e1-ab64-ba8d8cb1f80f.png) ### Expected Behavior Move all selected locations with "bulk edit" to the correct parent location. ### Observed Behavior Rooms seems to be in more than one parent location and some location objects not moveable/editable any more, even if want to remove(Set Null) the parent in the location object, independent of the edit mode I used. In some situations I also get an server error if I want to remove a parent of a location. Like this location object ![image](https://user-images.githubusercontent.com/114069964/202561176-4b9ba5ca-c888-4d79-9f27-079b17bbcaef.png) In edit location I removed the parent location and get this error message. ![image](https://user-images.githubusercontent.com/114069964/202559494-e83f6604-d327-4ea4-9f87-d5d320e61c1e.png) Complete error message: > <class 'django.db.utils.IntegrityError'> > > new row for relation "dcim_location" violates check constraint "dcim_location_level_check" > DETAIL: Failing row contains (2022-11-17 14:15:01.236855+00, 2022-11-17 14:15:01.236905+00, {}, 30, building A - ground, building-a-ground, , 2, 23, 2, -1, 27, 1, null, active). > > > Python version: 3.10.6 > NetBox version: 3.3.8
adam added the type: bugpending closurestatus: revisions needed labels 2025-12-29 20:20:31 +01:00
adam closed this issue 2025-12-29 20:20:31 +01:00
Author
Owner

@arthanson commented on GitHub (Nov 9, 2022):

Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.

@arthanson commented on GitHub (Nov 9, 2022): Thank you for opening a bug report. Unfortunately, the information you have provided is not sufficient for someone else to attempt to reproduce the reported behavior. Remember, each bug report must include detailed steps that someone else can follow on a clean, empty NetBox installation to reproduce the exact problem you're experiencing. These instructions should include the creation of any involved objects, any configuration changes, and complete accounting of the actions being taken. Also be sure that your report does not reference data on the public NetBox demo, as that is subject to change at any time by an outside party and cannot be relied upon for bug reports.
Author
Owner

@mscpik commented on GitHub (Nov 17, 2022):

I have edited the original bug report and using a fresh install of https://github.com/netbox-community/netbox-docker to test.
It is very hard to reproduce the error and in my opinion it has to do with [Bulk Edit] of locations.
With direct editing/changing the parent of a location where seems to be no problems.

@mscpik commented on GitHub (Nov 17, 2022): I have edited the original bug report and using a fresh install of https://github.com/netbox-community/netbox-docker to test. It is very hard to reproduce the error and in my opinion it has to do with [Bulk Edit] of locations. With direct editing/changing the parent of a location where seems to be no problems.
Author
Owner

@mscpik commented on GitHub (Nov 19, 2022):

In search of a solution to repair my productive database I found this older closed bug report:
"Misassignment of Locations parents" #9196

The method to rebuild location objects from nbshell worked to correct the parent child relations between the locations.

@mscpik commented on GitHub (Nov 19, 2022): In search of a solution to repair my productive database I found this older closed bug report: "Misassignment of Locations parents" #9196 The method to rebuild location objects from nbshell worked to correct the parent child relations between the locations.
Author
Owner

@arthanson commented on GitHub (Dec 2, 2022):

Potentially dependent on #6587

@arthanson commented on GitHub (Dec 2, 2022): Potentially dependent on #6587
Author
Owner

@mscpik commented on GitHub (Dec 8, 2022):

Potentially dependent on #6587

You might be right
A description how MPTT tree works on https://github.com/netbox-community/netbox/discussions/8987#discussioncomment-2461021

@mscpik commented on GitHub (Dec 8, 2022): > Potentially dependent on #6587 You might be right A description how [MPTT tree](https://django-mptt.readthedocs.io/en/latest/index.html) works on https://github.com/netbox-community/netbox/discussions/8987#discussioncomment-2461021
Author
Owner

@github-actions[bot] commented on GitHub (Apr 6, 2023):

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. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Apr 6, 2023): 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. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (May 6, 2023):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (May 6, 2023): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7211