Skip to content

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

@Carbenium

Description

@Carbenium

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'

Metadata

Metadata

Assignees

Labels

status: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions