StagedChange: SerializerNotFound #8550

Closed
opened 2025-12-29 20:38:01 +01:00 by adam · 6 comments
Owner

Originally created by @minitriga on GitHub (Aug 31, 2023).

NetBox version

v3.5.8

Python version

3.8

Steps to Reproduce

Create a staged change and delete via the UI in a plugin. There is no UI for the StagedChange model but when using it in a plugin and deleting a staged change the following is raised:
netbox.api.exceptions.SerializerNotFound: Could not determine serializer for extras.StagedChange with prefix ''

Expected Behavior

I expect that the deletion of a branch or staged change would not fail. I think this is due to the model has the following mixin ChangeLoggedModel.

Observed Behavior

extras.api.serializers.StagedChangeSerializer
Internal Server Error: /plugins/ipfabric/sync/12/delete/
Traceback (most recent call last):
  File "/opt/netbox/netbox/utilities/api.py", line 33, in get_serializer_for_model
    return dynamic_import(serializer_name)
  File "/opt/netbox/netbox/utilities/utils.py", line 126, in dynamic_import
    mod = getattr(mod, comp)
AttributeError: module 'extras.api.serializers' has no attribute 'StagedChangeSerializer'

During handling of the above exception, another exception occurred:

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 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 375, in post
    obj.delete()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1118, in delete
    return collector.delete()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 458, in delete
    signals.pre_delete.send(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/opt/netbox/netbox/extras/signals.py", line 118, in handle_deleted_object
    enqueue_object(queue, instance, request.user, request.id, ObjectChangeActionChoices.ACTION_DELETE)
  File "/opt/netbox/netbox/extras/webhooks.py", line 73, in enqueue_object
    'data': serialize_for_webhook(instance),
  File "/opt/netbox/netbox/extras/webhooks.py", line 22, in serialize_for_webhook
    serializer_class = get_serializer_for_model(instance.__class__)
  File "/opt/netbox/netbox/utilities/api.py", line 35, in get_serializer_for_model
    raise SerializerNotFound(
netbox.api.exceptions.SerializerNotFound: Could not determine serializer for extras.StagedChange with prefix ''
Originally created by @minitriga on GitHub (Aug 31, 2023). ### NetBox version v3.5.8 ### Python version 3.8 ### Steps to Reproduce Create a staged change and delete via the UI in a plugin. There is no UI for the StagedChange model but when using it in a plugin and deleting a staged change the following is raised: ```netbox.api.exceptions.SerializerNotFound: Could not determine serializer for extras.StagedChange with prefix ''``` ### Expected Behavior I expect that the deletion of a branch or staged change would not fail. I think this is due to the model has the following mixin `ChangeLoggedModel`. ### Observed Behavior ``` extras.api.serializers.StagedChangeSerializer Internal Server Error: /plugins/ipfabric/sync/12/delete/ Traceback (most recent call last): File "/opt/netbox/netbox/utilities/api.py", line 33, in get_serializer_for_model return dynamic_import(serializer_name) File "/opt/netbox/netbox/utilities/utils.py", line 126, in dynamic_import mod = getattr(mod, comp) AttributeError: module 'extras.api.serializers' has no attribute 'StagedChangeSerializer' During handling of the above exception, another exception occurred: 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 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 99, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 375, in post obj.delete() File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1118, in delete return collector.delete() File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 458, in delete signals.pre_delete.send( File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send return [ File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp> (receiver, receiver(signal=self, sender=sender, **named)) File "/opt/netbox/netbox/extras/signals.py", line 118, in handle_deleted_object enqueue_object(queue, instance, request.user, request.id, ObjectChangeActionChoices.ACTION_DELETE) File "/opt/netbox/netbox/extras/webhooks.py", line 73, in enqueue_object 'data': serialize_for_webhook(instance), File "/opt/netbox/netbox/extras/webhooks.py", line 22, in serialize_for_webhook serializer_class = get_serializer_for_model(instance.__class__) File "/opt/netbox/netbox/utilities/api.py", line 35, in get_serializer_for_model raise SerializerNotFound( netbox.api.exceptions.SerializerNotFound: Could not determine serializer for extras.StagedChange with prefix '' ```
adam added the type: bugstatus: under reviewstatus: blockedseverity: medium labels 2025-12-29 20:38:01 +01:00
adam closed this issue 2025-12-29 20:38:01 +01:00
Author
Owner

@minitriga commented on GitHub (Aug 31, 2023):

I can implement some serializers for Branch and StagedChange models.

@minitriga commented on GitHub (Aug 31, 2023): I can implement some serializers for Branch and StagedChange models.
Author
Owner

@minitriga commented on GitHub (Aug 31, 2023):

Having looked how many staged changes there can be I dont think its worth having change ChangeLoggedModel on it. For example when ingesting some customer information using the staging method there can be up to 100k+ objects being altered. Deleting these takes very long due to the ChangeLoggedModel process.

@minitriga commented on GitHub (Aug 31, 2023): Having looked how many staged changes there can be I dont think its worth having change ChangeLoggedModel on it. For example when ingesting some customer information using the staging method there can be up to 100k+ objects being altered. Deleting these takes very long due to the ChangeLoggedModel process.
Author
Owner

@arthanson commented on GitHub (Oct 2, 2023):

@minitriga the SerializerNotFound can remain in this issue, for removing ChangeLoggedModel on StagedChange - that should be opened as a feature-request as it will cause database changes and need to go into a point release.

@arthanson commented on GitHub (Oct 2, 2023): @minitriga the SerializerNotFound can remain in this issue, for removing ChangeLoggedModel on StagedChange - that should be opened as a feature-request as it will cause database changes and need to go into a point release.
Author
Owner

@arthanson commented on GitHub (Dec 4, 2023):

@minitriga creating new deprecation #14424 as this removes functionality it would need to be discussed as a deprecation. Marking this as blocked on that issue. Blocked by #14424

@arthanson commented on GitHub (Dec 4, 2023): @minitriga creating new deprecation #14424 as this removes functionality it would need to be discussed as a deprecation. Marking this as blocked on that issue. Blocked by #14424
Author
Owner

@arthanson commented on GitHub (Dec 12, 2023):

This is fixed via #14424 so closing.

@arthanson commented on GitHub (Dec 12, 2023): This is fixed via #14424 so closing.
Author
Owner

@minitriga commented on GitHub (Jan 10, 2024):

@arthanson This looks to be still broken in 3.7 I have upgraded and I get the same issue:

Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
January 10, 2024 - 15:39:10
Django version 4.2.8, using settings 'netbox.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.

[10/Jan/2024 15:39:17] "GET /plugins/ipfabric/sync/1/ HTTP/1.1" 200 112087
[10/Jan/2024 15:39:19] "GET /plugins/ipfabric/sync/1/delete/ HTTP/1.1" 200 7065
[10/Jan/2024 15:39:19] "GET /__debug__/history_sidebar/?store_id=58e3fd2b7f8444b29927866e81aba754 HTTP/1.1" 200 9502
Internal Server Error: /plugins/ipfabric/sync/1/delete/
Traceback (most recent call last):
  File "/opt/netbox/netbox/utilities/api.py", line 32, in get_serializer_for_model
    return dynamic_import(serializer_name)
  File "/opt/netbox/netbox/utilities/utils.py", line 126, in dynamic_import
    mod = getattr(mod, comp)
AttributeError: module 'extras.api.serializers' has no attribute 'StagedChangeSerializer'. Did you mean: 'ObjectChangeSerializer'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/netbox/utilities/views.py", line 99, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 420, in post
    obj.delete()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1132, in delete
    return collector.delete()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 463, in delete
    signals.pre_delete.send(
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send
    return [
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/opt/netbox/netbox/extras/signals.py", line 125, in handle_deleted_object
    enqueue_object(queue, instance, request.user, request.id, ObjectChangeActionChoices.ACTION_DELETE)
  File "/opt/netbox/netbox/extras/events.py", line 67, in enqueue_object
    'data': serialize_for_event(instance),
  File "/opt/netbox/netbox/extras/events.py", line 28, in serialize_for_event
    serializer_class = get_serializer_for_model(instance.__class__)
  File "/opt/netbox/netbox/utilities/api.py", line 34, in get_serializer_for_model
    raise SerializerNotFound(
netbox.api.exceptions.SerializerNotFound: Could not determine serializer for extras.StagedChange with prefix ''
[10/Jan/2024 15:39:20] "POST /plugins/ipfabric/sync/1/delete/ HTTP/1.1" 500 172606
(venv) root@asd:/opt/netbox/netbox# python3 manage.py nbshell
### NetBox interactive shell (sa-alex-gittings-netboxdev)
### Python 3.10.12 | Django 4.2.8 | NetBox 3.7.0
### lsmodels() will show available models. Use help(<model>) for more info.
>>> from django.conf import settings
>>> settings.VERSION
'3.7.0'
@minitriga commented on GitHub (Jan 10, 2024): @arthanson This looks to be still broken in 3.7 I have upgraded and I get the same issue: ``` Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). January 10, 2024 - 15:39:10 Django version 4.2.8, using settings 'netbox.settings' Starting development server at http://0.0.0.0:8000/ Quit the server with CONTROL-C. [10/Jan/2024 15:39:17] "GET /plugins/ipfabric/sync/1/ HTTP/1.1" 200 112087 [10/Jan/2024 15:39:19] "GET /plugins/ipfabric/sync/1/delete/ HTTP/1.1" 200 7065 [10/Jan/2024 15:39:19] "GET /__debug__/history_sidebar/?store_id=58e3fd2b7f8444b29927866e81aba754 HTTP/1.1" 200 9502 Internal Server Error: /plugins/ipfabric/sync/1/delete/ Traceback (most recent call last): File "/opt/netbox/netbox/utilities/api.py", line 32, in get_serializer_for_model return dynamic_import(serializer_name) File "/opt/netbox/netbox/utilities/utils.py", line 126, in dynamic_import mod = getattr(mod, comp) AttributeError: module 'extras.api.serializers' has no attribute 'StagedChangeSerializer'. Did you mean: 'ObjectChangeSerializer'? During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/netbox/utilities/views.py", line 99, in dispatch return super().dispatch(request, *args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch return handler(request, *args, **kwargs) File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 420, in post obj.delete() File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/base.py", line 1132, in delete return collector.delete() File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/deletion.py", line 463, in delete signals.pre_delete.send( File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 176, in send return [ File "/opt/netbox/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp> (receiver, receiver(signal=self, sender=sender, **named)) File "/opt/netbox/netbox/extras/signals.py", line 125, in handle_deleted_object enqueue_object(queue, instance, request.user, request.id, ObjectChangeActionChoices.ACTION_DELETE) File "/opt/netbox/netbox/extras/events.py", line 67, in enqueue_object 'data': serialize_for_event(instance), File "/opt/netbox/netbox/extras/events.py", line 28, in serialize_for_event serializer_class = get_serializer_for_model(instance.__class__) File "/opt/netbox/netbox/utilities/api.py", line 34, in get_serializer_for_model raise SerializerNotFound( netbox.api.exceptions.SerializerNotFound: Could not determine serializer for extras.StagedChange with prefix '' [10/Jan/2024 15:39:20] "POST /plugins/ipfabric/sync/1/delete/ HTTP/1.1" 500 172606 (venv) root@asd:/opt/netbox/netbox# python3 manage.py nbshell ### NetBox interactive shell (sa-alex-gittings-netboxdev) ### Python 3.10.12 | Django 4.2.8 | NetBox 3.7.0 ### lsmodels() will show available models. Use help(<model>) for more info. >>> from django.conf import settings >>> settings.VERSION '3.7.0' ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8550