-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
severity: lowDoes not significantly disrupt application functionality, or a workaround is availableDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application
Description
Deployment Type
Self-hosted
Triage priority
N/A
NetBox Version
v4.1.6
Python Version
3.11
Steps to Reproduce
Unable to execute custom scripts via the CLI and API. This is the same issue referenced in #17885. The fix implemented only applies to the GUI.
Adding the script name as an argument to the enqueue method fixes the problem.
netbox/netbox/extras/api/views.py
Lines 281 to 290 in 27d1561
| ScriptJob.enqueue( | |
| instance=script, | |
| user=request.user, | |
| data=input_serializer.data['data'], | |
| request=copy_safe_request(request), | |
| commit=input_serializer.data['commit'], | |
| job_timeout=script.python_class.job_timeout, | |
| schedule_at=input_serializer.validated_data.get('schedule_at'), | |
| interval=input_serializer.validated_data.get('interval') | |
| ) |
netbox/netbox/extras/management/commands/runscript.py
Lines 84 to 100 in 27d1561
| # Execute the script. | |
| job = ScriptJob.enqueue( | |
| instance=script_obj, | |
| user=user, | |
| immediate=True, | |
| data=data, | |
| request=NetBoxFakeRequest({ | |
| 'META': {}, | |
| 'POST': data, | |
| 'GET': {}, | |
| 'FILES': {}, | |
| 'user': user, | |
| 'path': '', | |
| 'id': uuid.uuid4() | |
| }), | |
| commit=commit, | |
| ) |
Expected Behavior
Executing a script for the CLI and API should work
Observed Behavior
The following error is produced when attempting to use the CLI runscript command
File "/opt/netbox/netbox/extras/management/commands/runscript.py", line 85, in handle
job = ScriptJob.enqueue(
^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/netbox/jobs.py", line 106, in enqueue
return Job.enqueue(cls.handle, name=name, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox/netbox/core/models/jobs.py", line 236, in enqueue
job.full_clean()
File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1561, in full_clean
raise ValidationError(errors)
django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']}
cruse1977, llamafilm, akgerrish, julianstolp, tecora and 7 more
Metadata
Metadata
Assignees
Labels
severity: lowDoes not significantly disrupt application functionality, or a workaround is availableDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the applicationA confirmed report of unexpected behavior in the application