Exception occured after device deletion #3365

Closed
opened 2025-12-29 18:28:21 +01:00 by adam · 4 comments
Owner

Originally created by @subzer0iq on GitHub (Feb 21, 2020).

Environment

  • Python version: 3.6.8
  • NetBox version: 2.7.7

Steps to Reproduce

  1. Enter in the any device
  2. Connect any port of this device to another device port
  3. Then delete device that you are entered in 1st step

Expected Behavior

Device successfully deleted.

Observed Behavior

Device deleted, but exception occured.
2020-02-21-11-14-29-v277

Originally created by @subzer0iq on GitHub (Feb 21, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.8<!-- Example: 3.6.9 --> * NetBox version: 2.7.7<!-- Example: 2.7.3 --> <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Enter in the any device 2. Connect any port of this device to another device port 3. Then delete device that you are entered in 1st step <!-- What did you expect to happen? --> ### Expected Behavior Device successfully deleted. <!-- What happened instead? --> ### Observed Behavior Device deleted, but exception occured. ![2020-02-21-11-14-29-v277](https://user-images.githubusercontent.com/30766229/75016649-83bc2b80-549c-11ea-9a6d-f4ba5d9a68a0.png)
adam added the type: bugstatus: accepted labels 2025-12-29 18:28:22 +01:00
adam closed this issue 2025-12-29 18:28:22 +01:00
Author
Owner

@hSaria commented on GitHub (Feb 21, 2020):

I couldn't replicate this issue. I tried to delete through the device's view (/dcim/devices/1/delete/) and bulk one (/dcim/devices/delete/).

@hSaria commented on GitHub (Feb 21, 2020): I couldn't replicate this issue. I tried to delete through the device's view (`/dcim/devices/1/delete/`) and bulk one (`/dcim/devices/delete/`).
Author
Owner

@subzer0iq commented on GitHub (Feb 21, 2020):

I couldn't replicate this issue. I tried to delete through the device's view (/dcim/devices/1/delete/) and bulk one (/dcim/devices/delete/).

I've figured out that webhook (dcim>interface) must be configured. Without webhook, there are no exception, in my case too.

@subzer0iq commented on GitHub (Feb 21, 2020): > I couldn't replicate this issue. I tried to delete through the device's view (`/dcim/devices/1/delete/`) and bulk one (`/dcim/devices/delete/`). I've figured out that webhook (dcim>interface) must be configured. Without webhook, there are no exception, in my case too.
Author
Owner

@kobayashi commented on GitHub (Feb 21, 2020):

Do you have chance to let us know the exact steps to reproduce this?
Please Traceback also.

@kobayashi commented on GitHub (Feb 21, 2020): Do you have chance to let us know the exact steps to reproduce this? Please Traceback also.
Author
Owner

@subzer0iq commented on GitHub (Feb 21, 2020):

Do you have chance to let us know the exact steps to reproduce this?
Please Traceback also.

  1. Go to Admin -> Webhooks -> Add WEBHOOK
  2. Then select
    Object types:
    dcim>interface
    Name:
    wh1
    Type create:
    Checkbox yes
    Type update:
    Checkbox yes
    Type delete:
    Checkbox yes

URL:
http://127.0.0.1:8002
HTTP content type:
Json
Enabled:
Checkbox yes
3. Click SAVE
4. Enter in the any device
5. Connect any port of this device to another device port (in my case SFP+ (10GE))
6. Then delete device that you are entered in 4th step (in the device view)

Traceback:

File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in __get__
  164.             rel_obj = self.field.get_cached_value(instance)

File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/mixins.py" in get_cached_value
  13.             return instance._state.fields_cache[cache_name]

During handling of the above exception ('_connected_interface'), another exception occurred:

File "/home/nb/lib64/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "./extras/middleware.py" in __call__
  117.             enqueue_webhooks(instance, request.user, request.id, action)

File "./extras/webhooks.py" in enqueue_webhooks
  63.                 serializer.data,

File "/home/nb/lib64/python3.6/site-packages/rest_framework/serializers.py" in data
  559.         ret = super().data

File "/home/nb/lib64/python3.6/site-packages/rest_framework/serializers.py" in data
  261.                 self._data = self.to_representation(self.instance)

File "/home/nb/lib64/python3.6/site-packages/rest_framework/serializers.py" in to_representation
  526.                 ret[field.field_name] = field.to_representation(attribute)

File "/home/nb/lib64/python3.6/site-packages/rest_framework/fields.py" in to_representation
  1873.         return method(value)

File "./dcim/api/serializers.py" in get_connected_endpoint_type
  35.         if hasattr(obj, 'connected_endpoint') and obj.connected_endpoint is not None:

File "./dcim/models/device_components.py" in connected_endpoint
  720.         if self._connected_interface:

File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in __get__
  178.                 rel_obj = self.get_object(instance)

File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get_object
  298.         return super().get_object(instance)

File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get_object
  145.         return qs.get(self.field.get_reverse_related_filter(instance))

File "/home/nb/lib64/python3.6/site-packages/cacheops/query.py" in get
  390.         return qs._no_monkey.get(qs, *args, **kwargs)

File "/home/nb/lib64/python3.6/site-packages/django/db/models/query.py" in get
  408.                 self.model._meta.object_name

Exception Type: DoesNotExist at /dcim/devices/81/delete/
Exception Value: Interface matching query does not exist.
@subzer0iq commented on GitHub (Feb 21, 2020): > Do you have chance to let us know the exact steps to reproduce this? > Please Traceback also. 1. Go to Admin -> Webhooks -> Add WEBHOOK 2. Then select **Object types:** dcim>interface **Name:** wh1 **Type create:** Checkbox yes **Type update:** Checkbox yes **Type delete:** Checkbox yes **URL:** http://127.0.0.1:8002 **HTTP content type:** Json **Enabled:** Checkbox yes 3. Click SAVE 4. Enter in the any device 5. Connect any port of this device to another device port (in my case SFP+ (10GE)) 6. Then delete device that you are entered in 4th step (in the device view) Traceback: ``` File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in __get__ 164. rel_obj = self.field.get_cached_value(instance) File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/mixins.py" in get_cached_value 13. return instance._state.fields_cache[cache_name] During handling of the above exception ('_connected_interface'), another exception occurred: File "/home/nb/lib64/python3.6/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "./extras/middleware.py" in __call__ 117. enqueue_webhooks(instance, request.user, request.id, action) File "./extras/webhooks.py" in enqueue_webhooks 63. serializer.data, File "/home/nb/lib64/python3.6/site-packages/rest_framework/serializers.py" in data 559. ret = super().data File "/home/nb/lib64/python3.6/site-packages/rest_framework/serializers.py" in data 261. self._data = self.to_representation(self.instance) File "/home/nb/lib64/python3.6/site-packages/rest_framework/serializers.py" in to_representation 526. ret[field.field_name] = field.to_representation(attribute) File "/home/nb/lib64/python3.6/site-packages/rest_framework/fields.py" in to_representation 1873. return method(value) File "./dcim/api/serializers.py" in get_connected_endpoint_type 35. if hasattr(obj, 'connected_endpoint') and obj.connected_endpoint is not None: File "./dcim/models/device_components.py" in connected_endpoint 720. if self._connected_interface: File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in __get__ 178. rel_obj = self.get_object(instance) File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get_object 298. return super().get_object(instance) File "/home/nb/lib64/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in get_object 145. return qs.get(self.field.get_reverse_related_filter(instance)) File "/home/nb/lib64/python3.6/site-packages/cacheops/query.py" in get 390. return qs._no_monkey.get(qs, *args, **kwargs) File "/home/nb/lib64/python3.6/site-packages/django/db/models/query.py" in get 408. self.model._meta.object_name Exception Type: DoesNotExist at /dcim/devices/81/delete/ Exception Value: Interface matching query does not exist. ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3365