Skip to content

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

@jeremystretch

Description

@jeremystretch

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.

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions