Create a new cable on an already used interface (API) #7236

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

Originally created by @Etibru on GitHub (Nov 16, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3.7

Python version

3.9

Steps to Reproduce

  1. Create a cable between 2 blank interfaces
    Using api to create a cable (/api/dcim/cables/)
data_cable = {
        "a_terminations": [
            {
                "object_type": "dcim.interface",
                "object_id": 31,
            },
        ],
        "b_terminations": [
            {
                "object_type": "dcim.interface",
                "object_id": 59,
            },
        ],
        "status": "connected",
    }

OK
2. Repeat with the same interface for B and another one for A

data_cable = {
        "a_terminations": [
            {
                "object_type": "dcim.interface",
                "object_id": 32,
            },
        ],
        "b_terminations": [
            {
                "object_type": "dcim.interface",
                "object_id": 59,
            },
        ],
        "status": "connected",
    }
  1. Error 500

Expected Behavior

Note the fact that the interface is already in use

Observed Behavior

django.db.utils.IntegrityError: duplicate key value violates unique constraint "dcim_cable_termination_unique_termination" DETAIL: Key (termination_type_id, termination_id)=(32, 59) already exists.

Originally created by @Etibru on GitHub (Nov 16, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3.7 ### Python version 3.9 ### Steps to Reproduce 1. Create a cable between 2 blank interfaces Using api to create a cable (/api/dcim/cables/) ``` data_cable = { "a_terminations": [ { "object_type": "dcim.interface", "object_id": 31, }, ], "b_terminations": [ { "object_type": "dcim.interface", "object_id": 59, }, ], "status": "connected", } ``` OK 2. Repeat with the same interface for B and another one for A ``` data_cable = { "a_terminations": [ { "object_type": "dcim.interface", "object_id": 32, }, ], "b_terminations": [ { "object_type": "dcim.interface", "object_id": 59, }, ], "status": "connected", } ``` 4. Error 500 ### Expected Behavior Note the fact that the interface is already in use ### Observed Behavior `django.db.utils.IntegrityError: duplicate key value violates unique constraint "dcim_cable_termination_unique_termination" DETAIL: Key (termination_type_id, termination_id)=(32, 59) already exists.`
adam added the type: bugstatus: accepted labels 2025-12-29 20:20:44 +01:00
adam closed this issue 2025-12-29 20:20:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#7236