Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
acederlund opened this issue Oct 29, 2024 · 2 comments · Fixed by #17886
Closed

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

acederlund opened this issue Oct 29, 2024 · 2 comments · Fixed by #17886
Assignees
Labels
netbox severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@acederlund
Copy link

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: #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

@acederlund acederlund added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Oct 29, 2024
@acederlund
Copy link
Author

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

@arthanson arthanson added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: needs triage This issue is awaiting triage by a maintainer labels Oct 29, 2024
@arthanson arthanson self-assigned this Oct 29, 2024
@arthanson arthanson added status: accepted This issue has been accepted for implementation and removed status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Oct 29, 2024
@jeremystretch jeremystretch added severity: high Completely breaks certain functions, or substantially degrades performance application-wide and removed severity: medium Results in substantial degraded or broken functionality for specfic workflows labels Oct 29, 2024
@netbox-community netbox-community deleted a comment from Arshnika Oct 30, 2024
@jeremystretch jeremystretch pinned this issue Oct 30, 2024
@jeremystretch jeremystretch unpinned this issue Oct 31, 2024
@alehaa
Copy link
Contributor

alehaa commented 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.

class Meta:
# An explicit job name is not set because it doesn't make sense in this context. Currently, there's no scenario
# where jobs other than this one are used. Therefore, it is hidden, resulting in a cleaner job table overview.
name = ''

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
netbox severity: high Completely breaks certain functions, or substantially degrades performance application-wide status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants