Deleting nested device roles in bulk via REST API results in duplicate change records #11415

Closed
opened 2025-12-29 21:44:57 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Jul 25, 2025).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.3.4

Python Version

3.10

Steps to Reproduce

  1. Create device role A with no parent.
  2. Create device role B as a child of role B.
  3. Note the IDs of both roles. (In this example, we assume their IDs are 1 and 2.)
  4. Delete both roles using a single REST API request:
curl -X DELETE \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://netbox:8000/api/dcim/device-roles/ \
--data '[
    {"id": 1},
    {"id": 2}
]'
  1. Inspect the change log.

Expected Behavior

The API request should generate only two deletion records (one for either role).

Observed Behavior

A duplicate deletion record is generated for the child role.

Image

I believe the first comes from the cascading deletion triggered by the deletion of the parent role; the second comes from the explicit deletion in the API request.

Originally created by @jeremystretch on GitHub (Jul 25, 2025). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.3.4 ### Python Version 3.10 ### Steps to Reproduce 1. Create device role A with no parent. 2. Create device role B as a child of role B. 3. Note the IDs of both roles. (In this example, we assume their IDs are 1 and 2.) 4. Delete both roles using a single REST API request: ```python curl -X DELETE \ -H "Authorization: Token $TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ http://netbox:8000/api/dcim/device-roles/ \ --data '[ {"id": 1}, {"id": 2} ]' ``` 5. Inspect the change log. ### Expected Behavior The API request should generate only two deletion records (one for either role). ### Observed Behavior A duplicate deletion record is generated for the child role. <img width="894" height="154" alt="Image" src="https://github.com/user-attachments/assets/308a3e31-0caf-4643-a4c5-10818a88290d" /> I believe the first comes from the cascading deletion triggered by the deletion of the parent role; the second comes from the explicit deletion in the API request.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:44:58 +01:00
adam closed this issue 2025-12-29 21:44:58 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jul 25, 2025):

I believe this occurs for any similar nested objects, such as inventory items.

@jeremystretch commented on GitHub (Jul 25, 2025): I believe this occurs for any similar nested objects, such as inventory items.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11415