AttributeError when de-assigning a primary IP from an interface #5248

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

Originally created by @Carbenium on GitHub (Aug 30, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.11.12

Python version

3.7

Steps to Reproduce

  1. Start editing an IP which is assigned to an interface and is the primary IP of the device.
  2. Delete content from the Device and Interface fields
  3. Click Update

Expected Behavior

IP should have been de-assigned from the interface.

Observed Behavior

The following exception is thrown:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic.py", line 260, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 98, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic.py", line 286, in post
    if form.is_valid():
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 175, in is_valid
    return self.is_bound and not self.errors
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 170, in errors
    self.full_clean()
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 374, in full_clean
    self._post_clean()
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/models.py", line 413, in _post_clean
    self.instance.full_clean(exclude=exclude, validate_unique=False)
  File "/opt/netbox/venv/lib/python3.7/site-packages/django/db/models/base.py", line 1223, in full_clean
    self.clean()
  File "/opt/netbox/netbox/ipam/models/ip.py", line 654, in clean
    if parent and getattr(self.assigned_object, attr) != parent:

Exception Type: AttributeError at /ipam/ip-addresses/22/edit/
Exception Value: 'NoneType' object has no attribute 'device'
Originally created by @Carbenium on GitHub (Aug 30, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.11.12 ### Python version 3.7 ### Steps to Reproduce 1. Start editing an IP which is assigned to an interface and is the primary IP of the device. 2. Delete content from the `Device` and `Interface` fields 3. Click `Update` ### Expected Behavior IP should have been de-assigned from the interface. ### Observed Behavior The following exception is thrown: ``` Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic.py", line 260, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 93, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 98, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic.py", line 286, in post if form.is_valid(): File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 175, in is_valid return self.is_bound and not self.errors File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 170, in errors self.full_clean() File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/forms.py", line 374, in full_clean self._post_clean() File "/opt/netbox/venv/lib/python3.7/site-packages/django/forms/models.py", line 413, in _post_clean self.instance.full_clean(exclude=exclude, validate_unique=False) File "/opt/netbox/venv/lib/python3.7/site-packages/django/db/models/base.py", line 1223, in full_clean self.clean() File "/opt/netbox/netbox/ipam/models/ip.py", line 654, in clean if parent and getattr(self.assigned_object, attr) != parent: Exception Type: AttributeError at /ipam/ip-addresses/22/edit/ Exception Value: 'NoneType' object has no attribute 'device' ```
adam added the type: bugstatus: accepted labels 2025-12-29 19:25:52 +01:00
adam closed this issue 2025-12-29 19:25:52 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5248