Error when assigning a VM interface to a parent interface #5044

Closed
opened 2025-12-29 19:23:29 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Jul 7, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.8

Python version

3.7

Steps to Reproduce

  1. Create a new VM and note its ID (ex: 123)
  2. Create interface eth0 on the VM and note its ID (ex: 456)
  3. Make a REST API call to create a second interface on the VM, assigning the first interface as its parent:
curl -X POST \
-H "Authorization: Token $TOKEN" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://netbox/api/virtualization/interfaces/ \
--data '{"virtual_machine": 123, "name": "new", "parent": 456}'

This was originally reported under #6709.

Expected Behavior

The second interface should be created successfully, with the first interface assigned as its parent.

Observed Behavior

One of two things might happen, depending on how many device interfaces have been created:

  1. A ValueError exception is raised.
  2. The following error is returned:
{
    "parent": [
        "Related object not found using the provided numeric ID: 456"
    ]
}

This is due a bug in the definition of NestedVirtualMachineSerializer, which incorrectly references the dcim.Interface model.

Originally created by @jeremystretch on GitHub (Jul 7, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.8 ### Python version 3.7 ### Steps to Reproduce 1. Create a new VM and note its ID (ex: 123) 2. Create interface eth0 on the VM and note its ID (ex: 456) 3. Make a REST API call to create a second interface on the VM, assigning the first interface as its parent: ``` curl -X POST \ -H "Authorization: Token $TOKEN" \ -H "Content-Type: application/json" \ -H "Accept: application/json; indent=4" \ http://netbox/api/virtualization/interfaces/ \ --data '{"virtual_machine": 123, "name": "new", "parent": 456}' ``` This was originally reported under #6709. ### Expected Behavior The second interface should be created successfully, with the first interface assigned as its parent. ### Observed Behavior One of two things might happen, depending on how many _device_ interfaces have been created: 1. A ValueError exception is raised. 2. The following error is returned: ``` { "parent": [ "Related object not found using the provided numeric ID: 456" ] } ``` This is due a bug in the definition of NestedVirtualMachineSerializer, which incorrectly references the dcim.Interface model.
adam added the type: bugstatus: accepted labels 2025-12-29 19:23:29 +01:00
adam closed this issue 2025-12-29 19:23:30 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5044