Webhook exception on object deleted event #2860

Closed
opened 2025-12-29 18:22:53 +01:00 by adam · 3 comments
Owner

Originally created by @candlerb on GitHub (Sep 9, 2019).

Environment

  • Python version: 3.5.2
  • NetBox version: 2.6.3

Steps to Reproduce

  1. Create a webhook on ipam.ipaddress pointing to a real http server
  2. Click IPAM > IP Address, Create. Enter an address and Save. (Note: the webhook is correctly triggered with 'created' event)
  3. Click "Delete this IP" then "Confirm"

Expected Behavior

Deletion to take place, together with post of a 'deleted' event to the webhook.

Observed Behavior

An exception is shown in the GUI, and no webhook HTTP request takes place.

image

Internal Server Error: /ipam/ip-addresses/114/delete/

ValueError at /ipam/ip-addresses/114/delete/
IPAddress objects need to have a primary key value before you can access their tags.

Request Method: POST
Request URL: http://netbox.home.example.net/ipam/ip-addresses/114/delete/
Django Version: 2.2.5
Python Executable: /usr/bin/python3
Python Version: 3.5.2
Python Path: ['/opt/netbox/netbox', '/usr/local/bin', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Mon, 9 Sep 2019 13:03:23 +0000
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cacheops',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'mptt',
 'rest_framework',
 'taggit',
 'taggit_serializer',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'drf_yasg',
 'django_rq']
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.ExceptionHandlingMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware',
 'extras.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware')


Traceback:

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

File "/opt/netbox/netbox/extras/middleware.py" in __call__
  100.             enqueue_webhooks(obj, request.user, request.id, objectchange.action)

File "/opt/netbox/netbox/extras/webhooks.py" in enqueue_webhooks
  47.                 serializer.data,

File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py" in data
  563.         ret = super(Serializer, self).data

File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py" in data
  262.                 self._data = self.to_representation(self.instance)

File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py" in to_representation
  517.                 attribute = field.get_attribute(instance)

File "/usr/local/lib/python3.5/dist-packages/rest_framework/fields.py" in get_attribute
  453.             return get_attribute(instance, self.source_attrs)

File "/usr/local/lib/python3.5/dist-packages/rest_framework/fields.py" in get_attribute
  101.                 instance = getattr(instance, attr)

File "/usr/local/lib/python3.5/dist-packages/taggit/managers.py" in __get__
  424.                 "before you can access their tags." % model.__name__

Exception Type: ValueError at /ipam/ip-addresses/114/delete/
Exception Value: IPAddress objects need to have a primary key value before you can access their tags.
Request information:
USER: admin

GET: No GET data

POST:
_confirm = ''
confirm = 'True'
return_url = ''
csrfmiddlewaretoken = 'fPMwosx3wpvd17zmZztvm8aPbgCXCAMUZ2MLQMgdzoA2Bksi23m836335IJ1DV0v'
Originally created by @candlerb on GitHub (Sep 9, 2019). ### Environment * Python version: 3.5.2 * NetBox version: 2.6.3 ### Steps to Reproduce 1. Create a webhook on `ipam.ipaddress` pointing to a real http server 2. Click IPAM > IP Address, Create. Enter an address and Save. (Note: the webhook is correctly triggered with 'created' event) 3. Click "Delete this IP" then "Confirm" ### Expected Behavior Deletion to take place, together with post of a 'deleted' event to the webhook. ### Observed Behavior An exception is shown in the GUI, and no webhook HTTP request takes place. ![image](https://user-images.githubusercontent.com/44789/64533245-f8464800-d30a-11e9-84b4-3f6b72816f97.png) ``` Internal Server Error: /ipam/ip-addresses/114/delete/ ValueError at /ipam/ip-addresses/114/delete/ IPAddress objects need to have a primary key value before you can access their tags. Request Method: POST Request URL: http://netbox.home.example.net/ipam/ip-addresses/114/delete/ Django Version: 2.2.5 Python Executable: /usr/bin/python3 Python Version: 3.5.2 Python Path: ['/opt/netbox/netbox', '/usr/local/bin', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages'] Server time: Mon, 9 Sep 2019 13:03:23 +0000 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'cacheops', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_tables2', 'django_prometheus', 'mptt', 'rest_framework', 'taggit', 'taggit_serializer', 'timezone_field', 'circuits', 'dcim', 'ipam', 'extras', 'secrets', 'tenancy', 'users', 'utilities', 'virtualization', 'drf_yasg', 'django_rq'] Installed Middleware: ('debug_toolbar.middleware.DebugToolbarMiddleware', 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'utilities.middleware.ExceptionHandlingMiddleware', 'utilities.middleware.LoginRequiredMiddleware', 'utilities.middleware.APIVersionMiddleware', 'extras.middleware.ObjectChangeMiddleware', 'django_prometheus.middleware.PrometheusAfterMiddleware') Traceback: File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request) File "/opt/netbox/netbox/extras/middleware.py" in __call__ 100. enqueue_webhooks(obj, request.user, request.id, objectchange.action) File "/opt/netbox/netbox/extras/webhooks.py" in enqueue_webhooks 47. serializer.data, File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py" in data 563. ret = super(Serializer, self).data File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py" in data 262. self._data = self.to_representation(self.instance) File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py" in to_representation 517. attribute = field.get_attribute(instance) File "/usr/local/lib/python3.5/dist-packages/rest_framework/fields.py" in get_attribute 453. return get_attribute(instance, self.source_attrs) File "/usr/local/lib/python3.5/dist-packages/rest_framework/fields.py" in get_attribute 101. instance = getattr(instance, attr) File "/usr/local/lib/python3.5/dist-packages/taggit/managers.py" in __get__ 424. "before you can access their tags." % model.__name__ Exception Type: ValueError at /ipam/ip-addresses/114/delete/ Exception Value: IPAddress objects need to have a primary key value before you can access their tags. Request information: USER: admin GET: No GET data POST: _confirm = '' confirm = 'True' return_url = '' csrfmiddlewaretoken = 'fPMwosx3wpvd17zmZztvm8aPbgCXCAMUZ2MLQMgdzoA2Bksi23m836335IJ1DV0v' ```
adam added the type: bugstatus: accepted labels 2025-12-29 18:22:53 +01:00
adam closed this issue 2025-12-29 18:22:53 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 9, 2019):

NetBox version: 2.5.3

Did you mean 2.6.3?

@jeremystretch commented on GitHub (Sep 9, 2019): > NetBox version: 2.5.3 Did you mean 2.6.3?
Author
Owner

@candlerb commented on GitHub (Sep 9, 2019):

Yes typo, sorry.

@candlerb commented on GitHub (Sep 9, 2019): Yes typo, sorry.
Author
Owner

@jchristopher327 commented on GitHub (Sep 9, 2019):

I was just going to open a similar issue but for when deleting devices. Similar error message and webhook triggered.

@jchristopher327 commented on GitHub (Sep 9, 2019): I was just going to open a similar issue but for when deleting devices. Similar error message and webhook triggered.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2860