-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
betaConcerns a bug/feature in a beta releaseConcerns a bug/feature in a beta releaseseverity: mediumResults in substantial degraded or broken functionality for specfic workflowsResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtopic: event rulesFor issues related to the Event Rules featureFor issues related to the Event Rules featuretype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
Deployment Type
Self-hosted
NetBox Version
4.0.0-beta2
Python Version
3.11
Steps to Reproduce
- Create a test custom script
from extras.scripts import Script
class Test(Script):
class Meta:
name = "Test Script"
def run(self, data, commit):
self.log_info("Test script executed")- Upload the script to the NetBox server
- Run the script manually to verify that it's working
4. Now create a new Event Rule for any object type, set the action type to 'Script' and select the test script created above
Expected Behavior
An event rule is created
Observed Behavior
Traceback (most recent call last):
File "/opt/netbox/lib64/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/netbox/views/generic/object_views.py", line 175, in dispatch
return super().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 108, in dispatch
return super().dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/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 269, in post
obj = form.save()
^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/django/forms/models.py", line 552, in save
self.instance.save()
^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/django/db/models/base.py", line 822, in save
self.save_base(
^
File "/opt/netbox/lib64/python3.11/site-packages/django/db/models/base.py", line 924, in save_base
post_save.send(
^
File "/opt/netbox/lib64/python3.11/site-packages/django/dispatch/dispatcher.py", line 189, in send
response = receiver(signal=self, sender=sender, **named)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/extras/signals.py", line 122, in handle_changed_object
enqueue_object(queue, instance, request.user, request.id, action)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/extras/events.py", line 65, in enqueue_object
'data': serialize_for_event(instance),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/extras/events.py", line 32, in serialize_for_event
return serializer.data
^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/serializers.py", line 571, in data
ret = super().data
^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/serializers.py", line 249, in data
self._data = self.to_representation(self.instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/serializers.py", line 538, in to_representation
ret[field.field_name] = field.to_representation(attribute)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/fields.py", line 1872, in to_representation
return method(value)
^^^^^^^^^^^^^
File "/opt/netbox/netbox/extras/api/serializers_/events.py", line 51, in get_action_object
return ScriptSerializer(instance, nested=True, context=context).data
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/serializers.py", line 571, in data
ret = super().data
^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/serializers.py", line 249, in data
self._data = self.to_representation(self.instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/serializers.py", line 538, in to_representation
ret[field.field_name] = field.to_representation(attribute)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/relations.py", line 396, in to_representation
url = self.get_url(value, self.view_name, request, format)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/lib64/python3.11/site-packages/rest_framework/relations.py", line 332, in get_url
lookup_value = getattr(obj, self.lookup_field)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Exception Type: AttributeError at /extras/event-rules/add/
Exception Value: 'Test' object has no attribute 'pk'
Metadata
Metadata
Assignees
Labels
betaConcerns a bug/feature in a beta releaseConcerns a bug/feature in a beta releaseseverity: mediumResults in substantial degraded or broken functionality for specfic workflowsResults in substantial degraded or broken functionality for specfic workflowsstatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtopic: event rulesFor issues related to the Event Rules featureFor issues related to the Event Rules featuretype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application