Internal Server Error during create new ip-address via API or pynetbox #3661

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

Originally created by @heineek on GitHub (May 8, 2020).

Environment

  • Python version: 3.8.0
  • NetBox version: 2.8.1

Steps to Reproduce

  1. Disable any installed plugins by commenting out the PLUGINS setting in
    configuration.py.
  2. Try to add new ip-address using pynetbox method nb.ipam.ip_addresses.create(data)
    OR
  3. Try to add new ip-address using built-in Swagger interface

Expected Behavior

The new IP-address would be crerated

Observed Behavior

Error 500: Internal Server Error and the following messages in log file:

Internal Server Error: /api/ipam/ip-addresses/
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/api.py", line 330, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/mixins.py", line 18, in create
    serializer.is_valid(raise_exception=True)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 235, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 430, in run_validation
    value = self.to_internal_value(data)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 487, in to_internal_value
    validated_value = field.run_validation(primitive_value)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 539, in run_validation
    (is_empty_value, data) = self.validate_empty_values(data)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 515, in validate_empty_values
    return (True, self.get_default())
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 493, in get_default
    return self.default()
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 264, in __call__
    return self.default()
TypeError: __call__() missing 1 required positional argument: 'serializer_field'

Note: updating the existing ip-address object with the same data dictionary is successful. Also if I try to create the IP-address manually via web interface all is OK: ip-address creates without any errors.

Originally created by @heineek on GitHub (May 8, 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, and that any plugins have been disabled. --> ### Environment * Python version: 3.8.0 * NetBox version: 2.8.1 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. 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 client library such as pynetbox. --> ### Steps to Reproduce 1. Disable any installed plugins by commenting out the `PLUGINS` setting in `configuration.py`. 2. Try to add new ip-address using pynetbox method nb.ipam.ip_addresses.create(data) OR 3. Try to add new ip-address using built-in Swagger interface <!-- What did you expect to happen? --> ### Expected Behavior The new IP-address would be crerated <!-- What happened instead? --> ### Observed Behavior Error 500: Internal Server Error and the following messages in log file: ``` Internal Server Error: /api/ipam/ip-addresses/ Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/rest_framework/viewsets.py", line 114, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/api.py", line 330, in dispatch return super().dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 505, in dispatch response = self.handle_exception(exc) File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 465, in handle_exception self.raise_uncaught_exception(exc) File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 476, in raise_uncaught_exception raise exc File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 502, in dispatch response = handler(request, *args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/rest_framework/mixins.py", line 18, in create serializer.is_valid(raise_exception=True) File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 235, in is_valid self._validated_data = self.run_validation(self.initial_data) File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 430, in run_validation value = self.to_internal_value(data) File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 487, in to_internal_value validated_value = field.run_validation(primitive_value) File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 539, in run_validation (is_empty_value, data) = self.validate_empty_values(data) File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 515, in validate_empty_values return (True, self.get_default()) File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 493, in get_default return self.default() File "/usr/local/lib/python3.6/dist-packages/rest_framework/fields.py", line 264, in __call__ return self.default() TypeError: __call__() missing 1 required positional argument: 'serializer_field' ``` Note: updating the existing ip-address object with the same data dictionary is successful. Also if I try to create the IP-address manually via web interface all is OK: ip-address creates without any errors.
adam added the status: revisions needed label 2025-12-29 18:30:26 +01:00
adam closed this issue 2025-12-29 18:30:26 +01:00
Author
Owner

@kobayashi commented on GitHub (May 8, 2020):

Could you let us know the POST data to reproduce?

While trying this through swagger ui, it worked.

{
  "address": "10.0.0.2/24"
}
@kobayashi commented on GitHub (May 8, 2020): Could you let us know the POST data to reproduce? While trying this through swagger ui, it worked. ``` { "address": "10.0.0.2/24" } ```
Author
Owner

@heineek commented on GitHub (May 8, 2020):

I try to POST this data:
{'address': '100.104.15.169/25'}

10.0.0.2/24

I've tried to add this address via Swagger, but the same error happens.
I can add any IP-address manually only from web form. In the same time PATH, PUT and DELETE methods work. Only POST method doesn't work now. My python code and dependencies have not been changed a long time ago, observed behavior began after upgrading the NetBox to version 2.8.1.

@heineek commented on GitHub (May 8, 2020): I try to POST this data: {'address': '100.104.15.169/25'} > 10.0.0.2/24 I've tried to add this address via Swagger, but the same error happens. I can add any IP-address manually only from web form. In the same time PATH, PUT and DELETE methods work. Only POST method doesn't work now. My python code and dependencies have not been changed a long time ago, observed behavior began after upgrading the NetBox to version 2.8.1.
Author
Owner

@kobayashi commented on GitHub (May 9, 2020):

I tried with the same version and could not reproduce. As you mentioned your dependency may related, can you try to upgrade? This page may be helpful.
GitHub issues are intended for reporting reproducible bugs and requesting features. For general discussion, questions, or assistance with installation issues, please post to our mailing list instead.

@kobayashi commented on GitHub (May 9, 2020): I tried with the same version and could not reproduce. As you mentioned your dependency may related, can you try to upgrade? [This page](https://netbox.readthedocs.io/en/stable/installation/upgrading/) may be helpful. GitHub issues are intended for reporting reproducible bugs and requesting features. For general discussion, questions, or assistance with installation issues, please post to our [mailing list](https://groups.google.com/forum/#!forum/netbox-discuss) instead.
Author
Owner

@heineek commented on GitHub (May 9, 2020):

So, I've resolved. After introducing the virtual environment you MUST edit /etc/systemd/system/netbox*.service and change the beginnigs of ExecParameter from "/usr/bin/[gunicorn, python3]..." to "/opt/netbox/venv/bin/[gunicorn, pyhton]...". The error described above happened because I did not edit these files and my NetBox used old versions of libraries from global environment instead its own one.

@heineek commented on GitHub (May 9, 2020): So, I've resolved. After introducing the virtual environment you MUST edit /etc/systemd/system/netbox*.service and change the beginnigs of ExecParameter from "/usr/bin/[gunicorn, python3]..." to "/opt/netbox/venv/bin/[gunicorn, pyhton]...". The error described above happened because I did not edit these files and my NetBox used old versions of libraries from global environment instead its own one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3661