PATCHing /api/dcim/interfaces/{id}/ without setting tagged_vlans drops tagged_vlans on interface #5566

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

Originally created by @afics on GitHub (Oct 27, 2021).

NetBox version

v3.0.8 and v2.11.12

Python version

3.7

Steps to Reproduce

PATCHing an interface at /api/interfaces/{id}/ with the "tagged_vlans" field missing removes all tagged VLANs from the interface.

To reproduce, please run nb-api-bug-requests.py like so NETBOX_URL=http://netbox/ NETBOX_TOKEN=api-token python3 nb-api-bug-requests.py

Expected Behavior

PATCHing an interface without tagged_vlans set should preserve already set tagged VLANs.
nb-api-bug-requests.py should return the following:

[{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)',
  'id': 7520,
  'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53',
  'url': 'http://netbox/api/ipam/vlans/7520/',
  'vid': 1234}]
[{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)',
  'id': 7520,
  'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53',
  'url': 'http://netbox/api/ipam/vlans/7520/',
  'vid': 1234}]
[{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)',
  'id': 7520,
  'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53',
  'url': 'http://netbox/api/ipam/vlans/7520/',
  'vid': 1234}]
[{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)',
  'id': 7520,
  'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53',
  'url': 'http://netbox/api/ipam/vlans/7520/',
  'vid': 1234}]

Observed Behavior

After PATCHing an interface tagged_vlans is empty.
nb-api-bug-requests.py returns the following:

[{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)',
  'id': 7520,
  'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53',
  'url': 'http://netbox/api/ipam/vlans/7520/',
  'vid': 1234}]
[{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)',
  'id': 7520,
  'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53',
  'url': 'http://netbox/api/ipam/vlans/7520/',
  'vid': 1234}]
[]
[]
Originally created by @afics on GitHub (Oct 27, 2021). ### NetBox version v3.0.8 and v2.11.12 ### Python version 3.7 ### Steps to Reproduce `PATCH`ing an interface at /api/interfaces/{id}/ with the "tagged_vlans" field missing removes all tagged VLANs from the interface. To reproduce, please run [nb-api-bug-requests.py](https://github.com/netbox-community/netbox/files/7425941/nb-api-bug-requests.py.txt) like so `NETBOX_URL=http://netbox/ NETBOX_TOKEN=api-token python3 nb-api-bug-requests.py` ### Expected Behavior `PATCH`ing an interface without `tagged_vlans` set should preserve already set tagged VLANs. `nb-api-bug-requests.py` should return the following: ``` [{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)', 'id': 7520, 'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53', 'url': 'http://netbox/api/ipam/vlans/7520/', 'vid': 1234}] [{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)', 'id': 7520, 'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53', 'url': 'http://netbox/api/ipam/vlans/7520/', 'vid': 1234}] [{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)', 'id': 7520, 'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53', 'url': 'http://netbox/api/ipam/vlans/7520/', 'vid': 1234}] [{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)', 'id': 7520, 'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53', 'url': 'http://netbox/api/ipam/vlans/7520/', 'vid': 1234}] ``` ### Observed Behavior After `PATCH`ing an interface `tagged_vlans` is empty. `nb-api-bug-requests.py` returns the following: ``` [{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)', 'id': 7520, 'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53', 'url': 'http://netbox/api/ipam/vlans/7520/', 'vid': 1234}] [{'display': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53 (1234)', 'id': 7520, 'name': 'test-vlan-29bed8aa-4cbd-43fa-844b-10e0fd27cf53', 'url': 'http://netbox/api/ipam/vlans/7520/', 'vid': 1234}] [] [] ```
adam closed this issue 2025-12-29 19:29:29 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 3, 2021):

When your script creates the interface, it doesn't specify an 802.1Q mode. The assigned VLANs are being cleared by the PATCH request because the mode is null. I can confirm that if the mode is set to tagged the assigned VLANs are preserved as expected.

@jeremystretch commented on GitHub (Nov 3, 2021): When your script creates the interface, it doesn't specify an 802.1Q mode. The assigned VLANs are being cleared by the PATCH request because the mode is null. I can confirm that if the mode is set to `tagged` the assigned VLANs are preserved as expected.
Author
Owner

@afics commented on GitHub (Nov 5, 2021):

Hi @jeremystretch,

I can confirm that if the mode is set to tagged the assigned VLANs are preserved as expected.

True, reproduced locally. I didn't notice that was missing, thanks!

Regards,
Armin

@afics commented on GitHub (Nov 5, 2021): Hi @jeremystretch, > I can confirm that if the mode is set to `tagged` the assigned VLANs are preserved as expected. True, reproduced locally. I didn't notice that was missing, thanks! Regards, Armin
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5566