ICTU / netbox_slm

Netbox Software Lifecycle Management Extension
Other
36 stars 7 forks source link

API Call to softwareproductinstallations show json invalid error #12

Closed ilimit-devops closed 1 year ago

ilimit-devops commented 1 year ago

<class 'TypeError'>

Object of type SoftwareProductInstallation is not JSON serializable

Python version: 3.10.6 NetBox version: 3.4.5 SLM version: 1.2

Error Log

Internal Server Error: /api/plugins/slm/softwareproductinstallations/
Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 723, in render
    context = self.get_context(data, accepted_media_type, renderer_context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 679, in get_context
    'content': self.get_content(renderer, data, accepted_media_type, renderer_context),
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 412, in get_content
    content = renderer.render(data, accepted_media_type, renderer_context)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/renderers.py", line 99, in render
    ret = json.dumps(
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/utils/json.py", line 25, in dumps
    return json.dumps(*args, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/opt/netbox/venv/lib/python3.10/site-packages/rest_framework/utils/encoders.py", line 67, in default
    return super().default(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type SoftwareProductInstallation is not JSON serializable
ilimit-devops commented 1 year ago

I think the problem is in this line: https://github.com/ICTU/netbox_slm/blob/a53486ca236328bc27eea8a78e84b51ea4c34849/netbox_slm/api/serializers.py#L55