Server Error on Interface disconnect #2172

Closed
opened 2025-12-29 17:22:59 +01:00 by adam · 5 comments
Owner

Originally created by @PeterG3 on GitHub (Dec 4, 2018).

Environment

  • Python version: v3.5.2
  • NetBox version: v2.4.6

Steps to Reproduce

  1. Create two devices
  2. Connect some interfaces
  3. Try to disconnect an interface and confirm this operation
  4. Server error is displayed

Sometimes it is working but in 9 of 10 cases we get those errors for up to 10 minutes and then the same disconnect operation is working fine.

Expected Behavior

The operation should not produce a internal server error.

Observed Behavior

Server Error

There was a problem with your request. Please contact an administrator.
The complete exception is provided below:

<class 'ValueError'>
Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x7f91c9aaae48>": "ObjectChange.user" must be a "User" instance.

Looks very familiar to issue 2621

Originally created by @PeterG3 on GitHub (Dec 4, 2018). ### Environment * Python version: v3.5.2 * NetBox version: v2.4.6 ### Steps to Reproduce 1. Create two devices 2. Connect some interfaces 3. Try to disconnect an interface and confirm this operation 4. Server error is displayed Sometimes it is working but in 9 of 10 cases we get those errors for up to 10 minutes and then the same disconnect operation is working fine. ### Expected Behavior The operation should not produce a internal server error. ### Observed Behavior Server Error There was a problem with your request. Please contact an administrator. The complete exception is provided below: <class 'ValueError'> Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x7f91c9aaae48>": "ObjectChange.user" must be a "User" instance. Looks very familiar to [issue 2621](https://github.com/digitalocean/netbox/issues/2621)
adam closed this issue 2025-12-29 17:22:59 +01:00
Author
Owner

@PeterG3 commented on GitHub (Dec 4, 2018):

We tried different users on different OS and browsers with several devices.

@PeterG3 commented on GitHub (Dec 4, 2018): We tried different users on different OS and browsers with several devices.
Author
Owner

@martink2 commented on GitHub (Dec 4, 2018):

This is the Stack Trace for the error

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/mixins.py" in dispatch
  85.         return super().dispatch(request, *args, **kwargs)

File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in dispatch
  89.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/dcim/views.py" in post
  1965.             interfaceconnection.delete()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in delete
  891.         return collector.delete()

File "/usr/local/lib/python3.5/dist-packages/django/db/models/deletion.py" in delete
  307.                             sender=model, instance=obj, using=self.using

File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in send
  178.             for receiver in self._live_receivers(sender)

File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in <listcomp>
  178.             for receiver in self._live_receivers(sender)

File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py" in _curried
  11.         return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs))

File "/opt/netbox/netbox/extras/middleware.py" in _record_object_deleted
  37.         instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE)

File "/opt/netbox/netbox/dcim/models.py" in log_change
  2098.                 object_data=serialize_object(interface, extra=connection_data)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in __init__
  477.                     _setattr(self, field.name, rel_obj)

File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/related_descriptors.py" in __set__
  197.                     self.field.remote_field.model._meta.object_name,

Exception Type: ValueError at /dcim/interface-connections/17421/delete/
Exception Value: Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x7f91c95aa470>": "ObjectChange.user" must be a "User" instance.
Request information:
USER: d043423

I am neither a python nor a django expert but from what googling reveals is that django.contrib.auth.models.AnonymousUser is a user which is not logged in, which in the case above is not the case. A line below in the error it even states the logged in user.

@jeremystretch is there anything more we can do to increase debugging ?

@martink2 commented on GitHub (Dec 4, 2018): This is the Stack Trace for the error ``` File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner 35. response = get_response(request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response 128. response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py" in _get_response 126. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in view 69. return self.dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/django/contrib/auth/mixins.py" in dispatch 85. return super().dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py" in dispatch 89. return handler(request, *args, **kwargs) File "/opt/netbox/netbox/dcim/views.py" in post 1965. interfaceconnection.delete() File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in delete 891. return collector.delete() File "/usr/local/lib/python3.5/dist-packages/django/db/models/deletion.py" in delete 307. sender=model, instance=obj, using=self.using File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in send 178. for receiver in self._live_receivers(sender) File "/usr/local/lib/python3.5/dist-packages/django/dispatch/dispatcher.py" in <listcomp> 178. for receiver in self._live_receivers(sender) File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py" in _curried 11. return _curried_func(*(args + moreargs), **dict(kwargs, **morekwargs)) File "/opt/netbox/netbox/extras/middleware.py" in _record_object_deleted 37. instance.log_change(request.user, request.id, OBJECTCHANGE_ACTION_DELETE) File "/opt/netbox/netbox/dcim/models.py" in log_change 2098. object_data=serialize_object(interface, extra=connection_data) File "/usr/local/lib/python3.5/dist-packages/django/db/models/base.py" in __init__ 477. _setattr(self, field.name, rel_obj) File "/usr/local/lib/python3.5/dist-packages/django/db/models/fields/related_descriptors.py" in __set__ 197. self.field.remote_field.model._meta.object_name, Exception Type: ValueError at /dcim/interface-connections/17421/delete/ Exception Value: Cannot assign "<django.contrib.auth.models.AnonymousUser object at 0x7f91c95aa470>": "ObjectChange.user" must be a "User" instance. Request information: USER: d043423 ``` I am neither a python nor a django expert but from what googling reveals is that django.contrib.auth.models.AnonymousUser is a user which is not logged in, which in the case above is not the case. A line below in the error it even states the logged in user. @jeremystretch is there anything more we can do to increase debugging ?
Author
Owner

@jeremystretch commented on GitHub (Dec 4, 2018):

Our requirement for accepting a bug report is that it must be reproducible on a clean installation of the latest release. Please see if you can reproduce this behavior on a clean installation of v2.4.8.

@jeremystretch commented on GitHub (Dec 4, 2018): Our requirement for accepting a bug report is that it must be reproducible on a clean installation of the latest release. Please see if you can reproduce this behavior on a clean installation of v2.4.8.
Author
Owner

@PeterG3 commented on GitHub (Dec 5, 2018):

After updating to v2.4.8 I encountered still the same issue after the first try.
Next step would be a clean install and test it again. Will keep you updated.

@PeterG3 commented on GitHub (Dec 5, 2018): After updating to v2.4.8 I encountered still the same issue after the first try. Next step would be a clean install and test it again. Will keep you updated.
Author
Owner

@jeremystretch commented on GitHub (Dec 19, 2018):

Closing due to inactivity. Please request to re-open if this issue is found to be reproducible on a recent stable release.

@jeremystretch commented on GitHub (Dec 19, 2018): Closing due to inactivity. Please request to re-open if this issue is found to be reproducible on a recent stable release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2172