Can't create VLAN resources through API with a reference to site,vlan-group #3589

Closed
opened 2025-12-29 18:30:02 +01:00 by adam · 1 comment
Owner

Originally created by @kr3ator on GitHub (Apr 21, 2020).

Environment

  • Python version: sameas in netbox-docker
  • NetBox version: 2.8.0
  • This is a clean, testing installation of netbox-docker

Steps to Reproduce

  1. Disable any installed plugins by commenting out the PLUGINS setting in
    configuration.py.
  2. Open Netbox Swagger API interface
  3. Create new VLAN-group with site defined through the API using:
curl -X POST "http://192.168.163.130:8000/api/ipam/vlan-groups/" -H "accept: application/json" -H "Content-Type: application/json" -H "X-CSRFToken: FpmEtE3MuOSNQME9PJIbXwv7pdYm1AlcUrwR9DBHnwAtkb63cm1lg0aaH6ckpsQX" -d "{ \"name\": \"DEV-GLOBAL\", \"slug\": \"dev\", \"site\": 8}"

Site 'Development' has been predefined:

{
   "id": 8,
   "name": "Development",
   "slug": "dev",
   "status": {
     "value": "active",
     "label": "Active",
     "id": 1
    },
  ......
}

No VLAN-groups had been defined.

Expected Behavior

VLAN group configured with specified parameters. Code 201 returned with return data as in the API definition.

Observed Behavior

API throws code 500 'Error: Internal Server Error'
In the response body I can see:

<pre><strong>&lt;class &#x27;AttributeError&#x27;&gt;</strong><br />
&#x27;UniqueTogetherValidator&#x27; object has no attribute &#x27;set_context&#x27;</pre>

Additional information

When reference to site ID (8) is ommited the VLAN group is created correctly.
After that, when trying to do a PATCH call to add the site to the just created vlan-group, the same error is thrown.

The same thing happens when I'm trying to create a VLAN (with site and/or group).
However, there seems to be no issues in the DCIM module as I was able to create a LAG (ref. to device id), then PATCH interface to add it to the LAG (ref. to LAG id) and finally create an IP and assign it to the interface.

Same behaviour is observed using different tools for making API requests.

Originally created by @kr3ator on GitHub (Apr 21, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: sameas in netbox-docker * NetBox version: 2.8.0 * This is a clean, testing installation of netbox-docker <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Disable any installed plugins by commenting out the `PLUGINS` setting in `configuration.py`. 2. Open Netbox Swagger API interface 3. Create new VLAN-group with site defined through the API using: ``` curl -X POST "http://192.168.163.130:8000/api/ipam/vlan-groups/" -H "accept: application/json" -H "Content-Type: application/json" -H "X-CSRFToken: FpmEtE3MuOSNQME9PJIbXwv7pdYm1AlcUrwR9DBHnwAtkb63cm1lg0aaH6ckpsQX" -d "{ \"name\": \"DEV-GLOBAL\", \"slug\": \"dev\", \"site\": 8}" ``` Site 'Development' has been predefined: ```json { "id": 8, "name": "Development", "slug": "dev", "status": { "value": "active", "label": "Active", "id": 1 }, ...... } ``` No VLAN-groups had been defined. <!-- What did you expect to happen? --> ### Expected Behavior VLAN group configured with specified parameters. Code 201 returned with return data as in the API definition. <!-- What happened instead? --> ### Observed Behavior API throws code 500 'Error: Internal Server Error' In the response body I can see: ```html <pre><strong>&lt;class &#x27;AttributeError&#x27;&gt;</strong><br /> &#x27;UniqueTogetherValidator&#x27; object has no attribute &#x27;set_context&#x27;</pre> ``` ### Additional information When reference to site ID (8) is ommited the VLAN group is created correctly. After that, when trying to do a PATCH call to add the site to the just created vlan-group, the same error is thrown. The same thing happens when I'm trying to create a VLAN (with site and/or group). However, there seems to be no issues in the DCIM module as I was able to create a LAG (ref. to device id), then PATCH interface to add it to the LAG (ref. to LAG id) and finally create an IP and assign it to the interface. Same behaviour is observed using different tools for making API requests.
adam closed this issue 2025-12-29 18:30:02 +01:00
Author
Owner

@DouglasHeriot commented on GitHub (Apr 21, 2020):

I ran into this as well. It's a duplicate issue of #4496 which has now been fixed in develop branch.

@DouglasHeriot commented on GitHub (Apr 21, 2020): I ran into this as well. It's a duplicate issue of #4496 which has now been fixed in `develop` branch.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3589