Failed to load API definition

155 views
Skip to first unread message

Ross Moutell

unread,
Feb 7, 2020, 4:20:45 AM2/7/20
to NetBox

I noticed this error on Netbox 2.7.3 and it persists on Netbox 2.7.4 when I click on the API link in the bottom right hand corner of my Netbox server.


error.png


However the API functionality appears to still work. I am not using it in anger so to speak but it returns information.


working error.png

Is this cosmetic error? Can it be ignored?


Thanks


Ross


Simon Meister

unread,
Feb 18, 2020, 6:28:17 PM2/18/20
to Ross Moutell, NetBox
Hello Ross,

We have the same issue. When we use mail requests against the api, the problem can sometimes occur.
I could get some error logs:

Feb 19 00:21:48 server9195 gunicorn[18064]: Internal Server Error: /api/docs/
Feb 19 00:21:48 server9195 gunicorn[18064]: Traceback (most recent call last):
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
Feb 19 00:21:48 server9195 gunicorn[18064]:    response = get_response(request)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
Feb 19 00:21:48 server9195 gunicorn[18064]:    response = self.process_exception_by_middleware(e, request)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
Feb 19 00:21:48 server9195 gunicorn[18064]:    response = wrapped_callback(request, *callback_args, **callback_kwargs)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
Feb 19 00:21:48 server9195 gunicorn[18064]:    return view_func(*args, **kwargs)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
Feb 19 00:21:48 server9195 gunicorn[18064]:    return self.dispatch(request, *args, **kwargs)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 505, in dispatch
Feb 19 00:21:48 server9195 gunicorn[18064]:    response = self.handle_exception(exc)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 465, in handle_exception
Feb 19 00:21:48 server9195 gunicorn[18064]:    self.raise_uncaught_exception(exc)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
Feb 19 00:21:48 server9195 gunicorn[18064]:    raise exc
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/rest_framework/views.py", line 502, in dispatch
Feb 19 00:21:48 server9195 gunicorn[18064]:    response = handler(request, *args, **kwargs)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/drf_yasg/views.py", line 94, in get
Feb 19 00:21:48 server9195 gunicorn[18064]:    schema = generator.get_schema(request, self.public)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/drf_yasg/generators.py", line 250, in get_schema
Feb 19 00:21:48 server9195 gunicorn[18064]:    endpoints = self.get_endpoints(request)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/drf_yasg/generators.py", line 325, in get_endpoints
Feb 19 00:21:48 server9195 gunicorn[18064]:    view = self.create_view(callback, method, request)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/drf_yasg/generators.py", line 281, in create_view
Feb 19 00:21:48 server9195 gunicorn[18064]:    view = self._gen.create_view(callback, method, request)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/rest_framework/schemas/generators.py", line 191, in create_view
Feb 19 00:21:48 server9195 gunicorn[18064]:    view = callback.cls(**getattr(callback, 'initkwargs', {}))
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/opt/netbox/netbox/utilities/api.py", line 353, in __init__
Feb 19 00:21:48 server9195 gunicorn[18064]:    serializer = serializer_class()
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/opt/netbox/netbox/extras/api/customfields.py", line 138, in __init__
Feb 19 00:21:48 server9195 gunicorn[18064]:    field_value = field.choices.get(value=field.default).pk
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
Feb 19 00:21:48 server9195 gunicorn[18064]:    return getattr(self.get_queryset(), name)(*args, **kwargs)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/cacheops/query.py", line 390, in get
Feb 19 00:21:48 server9195 gunicorn[18064]:    return qs._no_monkey.get(qs, *args, **kwargs)
Feb 19 00:21:48 server9195 gunicorn[18064]:  File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 408, in get
Feb 19 00:21:48 server9195 gunicorn[18064]:    self.model._meta.object_name
Feb 19 00:21:48 server9195 gunicorn[18064]: extras.models.CustomFieldChoice.DoesNotExist: CustomFieldChoice matching query does not exist.

Which operating system do you use?
We use CentOS 8 and I installed today the newest Netbox Version 2.7.6, the issue still persists.

Do you still have this issue?

Best regards,
Simon


--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/61e6de9d-bb49-4d8e-9c0c-8102af33f7ac%40googlegroups.com.

Jeremy Stretch

unread,
Feb 19, 2020, 10:58:12 AM2/19/20
to Simon Meister, Ross Moutell, NetBox
> When we use mail requests against the api, the problem can sometimes occur.

I don't know what you mean by that.

> extras.models.CustomFieldChoice.DoesNotExist: CustomFieldChoice matching query does not exist.

This would seem to suggest that the error involved custom field choices somehow. However, I'm not able to replicate this error even with selection custom fields in place.



--
Jeremy Stretch
Sr. Network Automation Engineer
Network to Code, LLC

Simon Meister

unread,
Feb 21, 2020, 5:27:31 AM2/21/20
to Jeremy Stretch, Ross Moutell, NetBox
Hello Jeremy,

Thanks a lot. I could solve the problem with your help.

The problem was that it is possible to create a custom field and define a default value that is not present in the selection, and I am 100% sure that this was not always the case because when we configured the custom field, it worked as expected.

Best regards,
Simon
Reply all
Reply to author
Forward
0 new messages