netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.24k stars 2.59k forks source link

manage.py runscript broken in 4.1.5 #17892

Closed llamafilm closed 2 weeks ago

llamafilm commented 2 weeks ago

Deployment Type

Self-hosted

Triage priority

I'm a NetBox Labs customer

NetBox Version

v4.1.5

Python Version

3.12

Steps to Reproduce

  1. Install Netbox from this commit 5f94dff81512e5fb687ccbc71883b2d629b1d091
  2. Run a script using manage.py runscript

Expected Behavior

no error

Observed Behavior

This looks like the same issue as #17885. This commit fixes the issue when running scripts in the GUI, but it's still broken in the CLI.

$ /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py runscript update_telegraf.UpdateTelegraf --commit
Traceback (most recent call last):
  File "/opt/netbox/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-5f94dff81512e5fb687ccbc71883b2d629b1d091/netbox/extras/management/commands/runscript.py", line 85, in handle
    job = ScriptJob.enqueue(
          ^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-5f94dff81512e5fb687ccbc71883b2d629b1d091/netbox/netbox/jobs.py", line 106, in enqueue
    return Job.enqueue(cls.handle, name=name, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox-5f94dff81512e5fb687ccbc71883b2d629b1d091/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.']}
jhofmueller commented 2 weeks ago

For me it does not work via the UI either. Just Tested with this very simple script:

class TestScript(Script):
    class Meta:
        name = "TestScript"

    def run(self, data, commit):
        self.log_info('Script started.')
        self.log_success('Script finished.')

got

Server Error

There was a problem with your request. Please contact an administrator.
The complete exception is provided below:
<class 'django.core.exceptions.ValidationError'>

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

Python version: 3.12.3
NetBox version: 4.1.5
Plugins: 
  netbox_dns: 1.1.5
  netbox_secrets: 2.1.0

If further assistance is required, please post to the [NetBox discussion forum](https://github.com/netbox-community/netbox/discussions) on GitHub.
[Home Page](https://localhost/)
ly-sona commented 2 weeks ago

having the exact same issue

theobarrague commented 2 weeks ago

Same issue 2024-10-31 13:18:06 UTC 3b9349c1ea55 NetBox Community v4.1.5 (docker)