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

Vlan group: Removing scope fails via api because scope_type does not allow nulls #10791

Closed
amhn opened this issue Oct 30, 2022 · 3 comments
Closed
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@amhn
Copy link
Contributor

amhn commented Oct 30, 2022

NetBox version

v3.3.6 && master

Python version

3.10

Steps to Reproduce

  1. Create site
  2. Create Vlan Group with scope
  3. Send {"scope_type": null, "scope_id": null} to /api/ipam/vlan-groups/ method PATCH

Expected Behavior

Scope is unset.

Observed Behavior

An error is returned:

{"scope_type":["This field may not be null."]}
@amhn amhn added the type: bug A confirmed report of unexpected behavior in the application label Oct 30, 2022
@amhn
Copy link
Contributor Author

amhn commented Oct 30, 2022

The following diff allows removing the scope via API:

diff --git a/netbox/ipam/api/serializers.py b/netbox/ipam/api/serializers.py
index fa8b563e9..eff39a418 100644
--- a/netbox/ipam/api/serializers.py
+++ b/netbox/ipam/api/serializers.py
@@ -175,6 +175,7 @@ class VLANGroupSerializer(NetBoxModelSerializer):
         queryset=ContentType.objects.filter(
             model__in=VLANGROUP_SCOPE_TYPES
         ),
+        allow_null=True,
         required=False,
         default=None
     )

@amhn
Copy link
Contributor Author

amhn commented Oct 31, 2022

Same problem and fix with the time_zone attribute of site:

diff --git a/netbox/dcim/api/serializers.py b/netbox/dcim/api/serializers.py
index 897ee4ca3..cb1edfe1f 100644
--- a/netbox/dcim/api/serializers.py
+++ b/netbox/dcim/api/serializers.py
@@ -130,7 +130,7 @@ class SiteSerializer(NetBoxModelSerializer):
     region = NestedRegionSerializer(required=False, allow_null=True)
     group = NestedSiteGroupSerializer(required=False, allow_null=True)
     tenant = NestedTenantSerializer(required=False, allow_null=True)
-    time_zone = TimeZoneSerializerField(required=False)
+    time_zone = TimeZoneSerializerField(required=False, allow_null=True)
     asns = SerializedPKRelatedField(
         queryset=ASN.objects.all(),
         serializer=NestedASNSerializer,

@jeremystretch
Copy link
Member

Same problem and fix with the time_zone attribute of site:

Please open a separate bug report for this.

@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Nov 1, 2022
@jeremystretch jeremystretch self-assigned this Nov 1, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants