Trying to create a network in non-existent site 3 crashes w/ a 500. This should return a 400, not a 500.
[2016-09-29 11:20:19 -0500] [83267] [ERROR] Internal Server Error: /api/sites/3/networks/
Traceback (most recent call last):
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/viewsets.py", line 87, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/views.py", line 474, in dispatch
response = self.handle_exception(exc)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/views.py", line 434, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/views.py", line 471, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework_bulk/drf3/mixins.py", line 29, in create
return super(BulkCreateModelMixin, self).create(request, *args, **kwargs)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/mixins.py", line 21, in create
self.perform_create(serializer)
File "/Users/jathan/Dropbox (Dropbox)/sandbox/src/nsot/nsot/api/views.py", line 190, in perform_create
objects = serializer.save()
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/serializers.py", line 192, in save
self.instance = self.create(validated_data)
File "/Users/jathan/Dropbox (Dropbox)/sandbox/src/nsot/nsot/api/serializers.py", line 232, in create
obj = super(ResourceSerializer, self).create(validated_data)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/rest_framework/serializers.py", line 873, in create
instance = ModelClass.objects.create(**validated_data)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/db/models/query.py", line 348, in create
obj.save(force_insert=True, using=self.db)
File "/Users/jathan/Dropbox (Dropbox)/sandbox/src/nsot/nsot/models.py", line 1090, in save
supernets = self.supernets(discover_mode=True, for_update=for_update)
File "/Users/jathan/Dropbox (Dropbox)/sandbox/src/nsot/nsot/models.py", line 741, in supernets
site=self.site,
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/db/models/fields/related.py", line 614, in __get__
rel_obj = qs.get()
File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/db/models/query.py", line 334, in get
self.model._meta.object_name
DoesNotExist: Site matching query does not exist.
[2016-09-29 11:20:20 -0500] [83267] [INFO] 500 POST /api/sites/3/networks/ (127.0.0.1) 364.75ms
Trying to create a network in non-existent site 3 crashes w/ a 500. This should return a 400, not a 500.