Fix #17685 seems to break script functionality in 4.1.5 #10417

Closed
opened 2025-12-29 21:31:12 +01:00 by adam · 2 comments
Owner

Originally created by @acederlund on GitHub (Oct 29, 2024).

Originally assigned to: @arthanson on GitHub.

Deployment Type

Self-hosted

Triage priority

N/A

NetBox Version

v4.1.5

Python Version

3.12

Steps to Reproduce

  1. Have scripts enabled in Netbox
  2. Try to run a script
  3. Netbox uses the job functionality to create a job, but does not provide a "name" for the job (as can be seen in previous jobs).
  4. A fault page is displayed

Expected Behavior

A job for the script was submitted, and output from the script was shown. Was working in v4.1.3 (we went straight from 4.1.3 to 4.1.5).

Problem seems to be related to these changes: https://github.com/netbox-community/netbox/pull/17847

Observed Behavior

`<class 'django.core.exceptions.ValidationError'>

{'name': ['This field cannot be blank.']}

Python version: 3.12.3
NetBox version: 4.1.5`

Log file says:
netbox-1 | 2024-10-29T14:52:01.481459179Z Initialized configuration netbox-1 | 2024-10-29T14:52:01.525754364Z Internal Server Error: /extras/scripts/2/ netbox-1 | 2024-10-29T14:52:01.525828197Z Traceback (most recent call last): netbox-1 | 2024-10-29T14:52:01.525832479Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner netbox-1 | 2024-10-29T14:52:01.525835327Z response = get_response(request) netbox-1 | 2024-10-29T14:52:01.525837521Z ^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525839747Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response netbox-1 | 2024-10-29T14:52:01.525842232Z response = wrapped_callback(request, *callback_args, **callback_kwargs) netbox-1 | 2024-10-29T14:52:01.525844385Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525846530Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view netbox-1 | 2024-10-29T14:52:01.525848922Z return self.dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525851221Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525853286Z File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch netbox-1 | 2024-10-29T14:52:01.525855462Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525857623Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525859696Z File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch netbox-1 | 2024-10-29T14:52:01.525861854Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525863888Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525865945Z File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch netbox-1 | 2024-10-29T14:52:01.525868267Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525870381Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525872525Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch netbox-1 | 2024-10-29T14:52:01.525874774Z return handler(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525899945Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525902029Z File "/opt/netbox/netbox/extras/views.py", line 1175, in post netbox-1 | 2024-10-29T14:52:01.525903704Z job = ScriptJob.enqueue( netbox-1 | 2024-10-29T14:52:01.525905171Z ^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525909231Z File "/opt/netbox/netbox/netbox/jobs.py", line 106, in enqueue netbox-1 | 2024-10-29T14:52:01.525910895Z return Job.enqueue(cls.handle, name=name, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525912581Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525914117Z File "/opt/netbox/netbox/core/models/jobs.py", line 236, in enqueue netbox-1 | 2024-10-29T14:52:01.525915757Z job.full_clean() netbox-1 | 2024-10-29T14:52:01.525917239Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1561, in full_clean netbox-1 | 2024-10-29T14:52:01.525918937Z raise ValidationError(errors) netbox-1 | 2024-10-29T14:52:01.525920928Z django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']} netbox-1 | 2024-10-29T14:52:01.525922608Z Cleared configuration

Originally created by @acederlund on GitHub (Oct 29, 2024). Originally assigned to: @arthanson on GitHub. ### Deployment Type Self-hosted ### Triage priority N/A ### NetBox Version v4.1.5 ### Python Version 3.12 ### Steps to Reproduce 1. Have scripts enabled in Netbox 2. Try to run a script 3. Netbox uses the job functionality to create a job, but does not provide a "name" for the job (as can be seen in previous jobs). 4. A fault page is displayed 5. ### Expected Behavior A job for the script was submitted, and output from the script was shown. Was working in v4.1.3 (we went straight from 4.1.3 to 4.1.5). Problem seems to be related to these changes: https://github.com/netbox-community/netbox/pull/17847 ### Observed Behavior `<class 'django.core.exceptions.ValidationError'> {'name': ['This field cannot be blank.']} Python version: 3.12.3 NetBox version: 4.1.5` Log file says: `netbox-1 | 2024-10-29T14:52:01.481459179Z Initialized configuration netbox-1 | 2024-10-29T14:52:01.525754364Z Internal Server Error: /extras/scripts/2/ netbox-1 | 2024-10-29T14:52:01.525828197Z Traceback (most recent call last): netbox-1 | 2024-10-29T14:52:01.525832479Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner netbox-1 | 2024-10-29T14:52:01.525835327Z response = get_response(request) netbox-1 | 2024-10-29T14:52:01.525837521Z ^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525839747Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response netbox-1 | 2024-10-29T14:52:01.525842232Z response = wrapped_callback(request, *callback_args, **callback_kwargs) netbox-1 | 2024-10-29T14:52:01.525844385Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525846530Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view netbox-1 | 2024-10-29T14:52:01.525848922Z return self.dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525851221Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525853286Z File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch netbox-1 | 2024-10-29T14:52:01.525855462Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525857623Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525859696Z File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch netbox-1 | 2024-10-29T14:52:01.525861854Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525863888Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525865945Z File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch netbox-1 | 2024-10-29T14:52:01.525868267Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525870381Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525872525Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch netbox-1 | 2024-10-29T14:52:01.525874774Z return handler(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525899945Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525902029Z File "/opt/netbox/netbox/extras/views.py", line 1175, in post netbox-1 | 2024-10-29T14:52:01.525903704Z job = ScriptJob.enqueue( netbox-1 | 2024-10-29T14:52:01.525905171Z ^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525909231Z File "/opt/netbox/netbox/netbox/jobs.py", line 106, in enqueue netbox-1 | 2024-10-29T14:52:01.525910895Z return Job.enqueue(cls.handle, name=name, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525912581Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525914117Z File "/opt/netbox/netbox/core/models/jobs.py", line 236, in enqueue netbox-1 | 2024-10-29T14:52:01.525915757Z job.full_clean() netbox-1 | 2024-10-29T14:52:01.525917239Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1561, in full_clean netbox-1 | 2024-10-29T14:52:01.525918937Z raise ValidationError(errors) netbox-1 | 2024-10-29T14:52:01.525920928Z django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']} netbox-1 | 2024-10-29T14:52:01.525922608Z Cleared configuration`
adam added the type: bugstatus: acceptednetboxseverity: high labels 2025-12-29 21:31:12 +01:00
adam closed this issue 2025-12-29 21:31:12 +01:00
Author
Owner

@acederlund commented on GitHub (Oct 29, 2024):

Apologies for the bad formatting when pasting the log file, here it is hopefully better formatted:



netbox-1               | 2024-10-29T14:52:01.481425394Z No previous configuration found in database; proceeding with default values
netbox-1               | 2024-10-29T14:52:01.481459179Z Initialized configuration
netbox-1               | 2024-10-29T14:52:01.525754364Z Internal Server Error: /extras/scripts/2/
netbox-1               | 2024-10-29T14:52:01.525828197Z Traceback (most recent call last):
netbox-1               | 2024-10-29T14:52:01.525832479Z   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
netbox-1               | 2024-10-29T14:52:01.525835327Z     response = get_response(request)
netbox-1               | 2024-10-29T14:52:01.525837521Z                ^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525839747Z   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
netbox-1               | 2024-10-29T14:52:01.525842232Z     response = wrapped_callback(request, *callback_args, **callback_kwargs)
netbox-1               | 2024-10-29T14:52:01.525844385Z                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525846530Z   File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view
netbox-1               | 2024-10-29T14:52:01.525848922Z     return self.dispatch(request, *args, **kwargs)
netbox-1               | 2024-10-29T14:52:01.525851221Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525853286Z   File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch
netbox-1               | 2024-10-29T14:52:01.525855462Z     return super().dispatch(request, *args, **kwargs)
netbox-1               | 2024-10-29T14:52:01.525857623Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525859696Z   File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch
netbox-1               | 2024-10-29T14:52:01.525861854Z     return super().dispatch(request, *args, **kwargs)
netbox-1               | 2024-10-29T14:52:01.525863888Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525865945Z   File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch
netbox-1               | 2024-10-29T14:52:01.525868267Z     return super().dispatch(request, *args, **kwargs)
netbox-1               | 2024-10-29T14:52:01.525870381Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525872525Z   File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch
netbox-1               | 2024-10-29T14:52:01.525874774Z     return handler(request, *args, **kwargs)
netbox-1               | 2024-10-29T14:52:01.525899945Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525902029Z   File "/opt/netbox/netbox/extras/views.py", line 1175, in post
netbox-1               | 2024-10-29T14:52:01.525903704Z     job = ScriptJob.enqueue(
netbox-1               | 2024-10-29T14:52:01.525905171Z           ^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525909231Z   File "/opt/netbox/netbox/netbox/jobs.py", line 106, in enqueue
netbox-1               | 2024-10-29T14:52:01.525910895Z     return Job.enqueue(cls.handle, name=name, *args, **kwargs)
netbox-1               | 2024-10-29T14:52:01.525912581Z            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
netbox-1               | 2024-10-29T14:52:01.525914117Z   File "/opt/netbox/netbox/core/models/jobs.py", line 236, in enqueue
netbox-1               | 2024-10-29T14:52:01.525915757Z     job.full_clean()
netbox-1               | 2024-10-29T14:52:01.525917239Z   File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1561, in full_clean
netbox-1               | 2024-10-29T14:52:01.525918937Z     raise ValidationError(errors)
netbox-1               | 2024-10-29T14:52:01.525920928Z django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']}
netbox-1               | 2024-10-29T14:52:01.525922608Z Cleared configuration
@acederlund commented on GitHub (Oct 29, 2024): Apologies for the bad formatting when pasting the log file, here it is hopefully better formatted: ``` netbox-1 | 2024-10-29T14:52:01.481425394Z No previous configuration found in database; proceeding with default values netbox-1 | 2024-10-29T14:52:01.481459179Z Initialized configuration netbox-1 | 2024-10-29T14:52:01.525754364Z Internal Server Error: /extras/scripts/2/ netbox-1 | 2024-10-29T14:52:01.525828197Z Traceback (most recent call last): netbox-1 | 2024-10-29T14:52:01.525832479Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner netbox-1 | 2024-10-29T14:52:01.525835327Z response = get_response(request) netbox-1 | 2024-10-29T14:52:01.525837521Z ^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525839747Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response netbox-1 | 2024-10-29T14:52:01.525842232Z response = wrapped_callback(request, *callback_args, **callback_kwargs) netbox-1 | 2024-10-29T14:52:01.525844385Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525846530Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 104, in view netbox-1 | 2024-10-29T14:52:01.525848922Z return self.dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525851221Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525853286Z File "/opt/netbox/netbox/netbox/views/generic/base.py", line 26, in dispatch netbox-1 | 2024-10-29T14:52:01.525855462Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525857623Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525859696Z File "/opt/netbox/netbox/utilities/views.py", line 125, in dispatch netbox-1 | 2024-10-29T14:52:01.525861854Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525863888Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525865945Z File "/opt/netbox/netbox/utilities/views.py", line 39, in dispatch netbox-1 | 2024-10-29T14:52:01.525868267Z return super().dispatch(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525870381Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525872525Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/views/generic/base.py", line 143, in dispatch netbox-1 | 2024-10-29T14:52:01.525874774Z return handler(request, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525899945Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525902029Z File "/opt/netbox/netbox/extras/views.py", line 1175, in post netbox-1 | 2024-10-29T14:52:01.525903704Z job = ScriptJob.enqueue( netbox-1 | 2024-10-29T14:52:01.525905171Z ^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525909231Z File "/opt/netbox/netbox/netbox/jobs.py", line 106, in enqueue netbox-1 | 2024-10-29T14:52:01.525910895Z return Job.enqueue(cls.handle, name=name, *args, **kwargs) netbox-1 | 2024-10-29T14:52:01.525912581Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ netbox-1 | 2024-10-29T14:52:01.525914117Z File "/opt/netbox/netbox/core/models/jobs.py", line 236, in enqueue netbox-1 | 2024-10-29T14:52:01.525915757Z job.full_clean() netbox-1 | 2024-10-29T14:52:01.525917239Z File "/opt/netbox/venv/lib/python3.12/site-packages/django/db/models/base.py", line 1561, in full_clean netbox-1 | 2024-10-29T14:52:01.525918937Z raise ValidationError(errors) netbox-1 | 2024-10-29T14:52:01.525920928Z django.core.exceptions.ValidationError: {'name': ['This field cannot be blank.']} netbox-1 | 2024-10-29T14:52:01.525922608Z Cleared configuration ```
Author
Owner

@alehaa commented on GitHub (Oct 31, 2024):

Hmm. Sad I didn't see this issue before and tests didn't catch it.

The bug originates from the following code. The justification of this was to not have the script name twice (as job name and related object) listed in the job table. Just having "SciptJob" as generic name seemed a bit odd to me at that time. 58bc388457/netbox/extras/jobs.py (L24-L27)

Now having #17886 merged might lead to confusion for further maintenance, as the code mentioned above states the name is not set and on the other hand its set explicitly on enqueue. As I'm not allowed to file housekeeping issues, I'd like to ask a maintainer to do so: Reverting #17886 and removing the code linked above should fix the issue and avoid confusion. ScriptJob will be used as default name afterwards and the script linked as job object.

@alehaa commented on GitHub (Oct 31, 2024): Hmm. Sad I didn't see this issue before and tests didn't catch it. The bug originates from the following code. The justification of this was to not have the script name twice (as job name and related object) listed in the job table. Just having "SciptJob" as generic name seemed a bit odd to me at that time. https://github.com/netbox-community/netbox/blob/58bc3884578a98595b02d7d7412c83d41fc7bbfa/netbox/extras/jobs.py#L24-L27 Now having #17886 merged might lead to confusion for further maintenance, as the code mentioned above states the name is not set and on the other hand its set explicitly on enqueue. As I'm not allowed to file housekeeping issues, I'd like to ask a maintainer to do so: Reverting #17886 and removing the code linked above should fix the issue and avoid confusion. `ScriptJob` will be used as default name afterwards and the script linked as job object.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10417