Reverse for 'script_jobs' with arguments '('',)' not found #11052

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

Originally created by @krasotinpa on GitHub (Apr 17, 2025).

Originally assigned to: @DanSheps on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.2.7

Python Version

3.10

Steps to Reproduce

  1. Upgrade to v4.2.7
  2. Click https://netbox.site/extras/scripts/

Expected Behavior

Should be page with list of custom scripts

Observed Behavior

After upgrading to the version 4.2.7 got error:

NoReverseMatch at /extras/scripts/
Reverse for 'script_jobs' with arguments '('',)' not found. 2 pattern(s) tried: ['extras/scripts/(?P<module>[^/]+)\\.(?P<name>[^/]+)/jobs/\\Z', 'extras/scripts/(?P<pk>[0-9]+)/jobs/\\Z']
Request Method:	GET
Request URL:	https://netbox.bsh.local/extras/scripts/
Django Version:	5.1.8
Exception Type:	NoReverseMatch
Exception Value:	
Reverse for 'script_jobs' with arguments '('',)' not found. 2 pattern(s) tried: ['extras/scripts/(?P<module>[^/]+)\\.(?P<name>[^/]+)/jobs/\\Z', 'extras/scripts/(?P<pk>[0-9]+)/jobs/\\Z']
Exception Location:	/opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py, line 831, in _reverse_with_prefix
Raised during:	extras.views.ScriptListView
Python Executable:	/opt/netbox/venv/bin/python3
Python Version:	3.10.12
Python Path:	
['/opt/netbox/netbox',
 '/opt/netbox',
 '/opt/netbox/venv/bin',
 '/usr/lib/python310.zip',
 '/usr/lib/python3.10',
 '/usr/lib/python3.10/lib-dynload',
 '/opt/netbox/venv/lib/python3.10/site-packages']
Server time:	Thu, 17 Apr 2025 11:27:26 +0300
Originally created by @krasotinpa on GitHub (Apr 17, 2025). Originally assigned to: @DanSheps on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.2.7 ### Python Version 3.10 ### Steps to Reproduce 1. Upgrade to v4.2.7 2. Click https://netbox.site/extras/scripts/ ### Expected Behavior Should be page with list of custom scripts ### Observed Behavior After upgrading to the version 4.2.7 got error: ``` NoReverseMatch at /extras/scripts/ Reverse for 'script_jobs' with arguments '('',)' not found. 2 pattern(s) tried: ['extras/scripts/(?P<module>[^/]+)\\.(?P<name>[^/]+)/jobs/\\Z', 'extras/scripts/(?P<pk>[0-9]+)/jobs/\\Z'] Request Method: GET Request URL: https://netbox.bsh.local/extras/scripts/ Django Version: 5.1.8 Exception Type: NoReverseMatch Exception Value: Reverse for 'script_jobs' with arguments '('',)' not found. 2 pattern(s) tried: ['extras/scripts/(?P<module>[^/]+)\\.(?P<name>[^/]+)/jobs/\\Z', 'extras/scripts/(?P<pk>[0-9]+)/jobs/\\Z'] Exception Location: /opt/netbox/venv/lib/python3.10/site-packages/django/urls/resolvers.py, line 831, in _reverse_with_prefix Raised during: extras.views.ScriptListView Python Executable: /opt/netbox/venv/bin/python3 Python Version: 3.10.12 Python Path: ['/opt/netbox/netbox', '/opt/netbox', '/opt/netbox/venv/bin', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/opt/netbox/venv/lib/python3.10/site-packages'] Server time: Thu, 17 Apr 2025 11:27:26 +0300 ```
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 21:39:39 +01:00
adam closed this issue 2025-12-29 21:39:40 +01:00
Author
Owner

@krasotinpa commented on GitHub (Apr 17, 2025):

It is not NETBOX problem.
In my case it was error in the script. I've fix it and it is good.

@krasotinpa commented on GitHub (Apr 17, 2025): It is not NETBOX problem. In my case it was error in the script. I've fix it and it is good.
Author
Owner

@DanSheps commented on GitHub (Apr 23, 2025):

Well, this is actually a bug.

In 4.2.7 we added some logic to enforce script ordering. However that logic returns a tuple in some cases and the raw script in others, within the same list. Code here

    @property
    def ordered_scripts(self):
        script_objects = {s.name: s for s in self.scripts.all()}
        ordered = [
            script_objects.pop(sc) for sc in self.module_scripts.keys() if sc in script_objects
        ]
        ordered.extend(script_objects.items())
        return ordered

To fix it:

    @property
    def ordered_scripts(self):
        script_objects = {s.name: s for s in self.scripts.all()}
        ordered = [
            script_objects.pop(sc) for sc in self.module_scripts.keys() if sc in script_objects
        ]
-       ordered.extend(script_objects.items())
+       ordered.extend(script_objects.values())
        return ordered
@DanSheps commented on GitHub (Apr 23, 2025): Well, this is actually a bug. In 4.2.7 we added some logic to enforce script ordering. However that logic returns a tuple in some cases and the raw script in others, within the same list. Code here ``` @property def ordered_scripts(self): script_objects = {s.name: s for s in self.scripts.all()} ordered = [ script_objects.pop(sc) for sc in self.module_scripts.keys() if sc in script_objects ] ordered.extend(script_objects.items()) return ordered ``` To fix it: ```diff @property def ordered_scripts(self): script_objects = {s.name: s for s in self.scripts.all()} ordered = [ script_objects.pop(sc) for sc in self.module_scripts.keys() if sc in script_objects ] - ordered.extend(script_objects.items()) + ordered.extend(script_objects.values()) return ordered ```
Author
Owner

@DanSheps commented on GitHub (Apr 23, 2025):

The issue is, that in certain cirumstances (script is unable to be loaded), the following can be returned from ordered_scripts:

[
    <Script: Test Script #1>,
    <Script: Test Script #2>,
    <Script: Test Script #3>,
    ('Test Script #4', <Script: Test Script #4>)
]

When this is expected:

[
    <Script: Test Script #1>,
    <Script: Test Script #2>,
    <Script: Test Script #3>,
    <Script: Test Script #4>
]
@DanSheps commented on GitHub (Apr 23, 2025): The issue is, that in certain cirumstances (script is unable to be loaded), the following can be returned from `ordered_scripts`: ```python [ <Script: Test Script #1>, <Script: Test Script #2>, <Script: Test Script #3>, ('Test Script #4', <Script: Test Script #4>) ] ``` When this is expected: ```python [ <Script: Test Script #1>, <Script: Test Script #2>, <Script: Test Script #3>, <Script: Test Script #4> ] ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11052