Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create of VLAN using the API and /available-vlans/ fails when role or tenant is present #13440

Closed
einaram opened this issue Aug 10, 2023 · 5 comments
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: under review Further discussion is needed to determine this issue's scope and/or implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@einaram
Copy link

einaram commented Aug 10, 2023

NetBox version

v3.6-beta1

Python version

3.10

Steps to Reproduce

  1. Create a tenant and note the ID
  2. Create a VLAN group and note the ID
  3. Run a POST to `api/ipam/vlan-groups//available-vlans/ like:

curl -X 'POST' \
  'https://demo.netbox.dev/api/ipam/vlan-groups/2/available-vlans/' \
  -d '{
  "name": "a_VLAN_name",
  "tenant": 2
}'

Expected Behavior

A new VLAN should be created

Observed Behavior

Bad request is returned with an error message that indicates that the deserialization used the tenant object instead of the ID:

  "tenant": [
    "Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: Strickland Propane"
  ]
}
@einaram einaram added the type: bug A confirmed report of unexpected behavior in the application label Aug 10, 2023
einaram pushed a commit to einaram/netbox that referenced this issue Aug 10, 2023
einaram pushed a commit to einaram/netbox that referenced this issue Aug 10, 2023
@einaram
Copy link
Author

einaram commented Aug 10, 2023

I have tested possible solution by not deserializing requested_vlans and instead adding vid to the raw data. This, and tests modified to test this behavoir is available here:
develop...einaram:netbox:13440-fix-available-vlan-post

@einaram einaram changed the title Create of VLAN using the API and /available-vlans/ fails when role or tenant is sle Create of VLAN using the API and /available-vlans/ fails when role or tenant is present Aug 11, 2023
@einaram einaram changed the title Create of VLAN using the API and /available-vlans/ fails when role or tenant is present Create of VLAN using the API and /available-vlans/ fails when role or tenant are present Aug 11, 2023
@einaram einaram changed the title Create of VLAN using the API and /available-vlans/ fails when role or tenant are present Create of VLAN using the API and /available-vlans/ fails when role or tenant is present Aug 11, 2023
@jeremystretch
Copy link
Member

jeremystretch commented Aug 23, 2023

This and similar API endpoints were refactored recently in feature to use the new common AvailableObjectsView (see #12180), however the bug does still exist. Testing shows that tenant assignment works as expected when provisioning available IPs, but not for available VLANs. This is due to a difference between the serializers: CreateAvailableVLANSerializer defines a tenant field whereas AvailableIPSerializer does not.

Further investigation is needed to determine the appropriate fix. We need to ensure that all serializers that enable the automatic creation of "available" objects operate in a consistent manner.

@jeremystretch jeremystretch added status: under review Further discussion is needed to determine this issue's scope and/or implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows labels Aug 23, 2023
@jeremystretch
Copy link
Member

@arthanson this may be related to #13746

@arthanson
Copy link
Collaborator

This is fixed by #13746

@arthanson arthanson self-assigned this Sep 25, 2023
@jeremystretch
Copy link
Member

Confirmed that this has been resolved by PR #13889. Thanks @arthanson!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: under review Further discussion is needed to determine this issue's scope and/or implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants