Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook exception on object deleted event #3489

Closed
candlerb opened this issue Sep 9, 2019 · 3 comments
Closed

Webhook exception on object deleted event #3489

candlerb opened this issue Sep 9, 2019 · 3 comments
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@candlerb
Copy link
Contributor

candlerb commented 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'
@jeremystretch
Copy link
Member

NetBox version: 2.5.3

Did you mean 2.6.3?

@candlerb
Copy link
Contributor Author

candlerb commented Sep 9, 2019

Yes typo, sorry.

@jchristopher327
Copy link

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

@candlerb candlerb changed the title Webhook exception on ipam.ipaddress deleted event Webhook exception on object deleted event Sep 9, 2019
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Sep 9, 2019
marcoceppi pushed a commit to vapor-ware/netbox that referenced this issue Sep 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants