Skip to content

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

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

Closed
krasotinpa opened this issue Apr 17, 2025 · 3 comments · Fixed by #19293
Closed

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

krasotinpa opened this issue Apr 17, 2025 · 3 comments · Fixed by #19293
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Milestone

Comments

@krasotinpa
Copy link

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
@krasotinpa krasotinpa added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Apr 17, 2025
@krasotinpa
Copy link
Author

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

@jeremystretch jeremystretch closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2025
@jeremystretch jeremystretch removed type: bug A confirmed report of unexpected behavior in the application status: needs triage This issue is awaiting triage by a maintainer labels Apr 17, 2025
@DanSheps DanSheps reopened this Apr 23, 2025
@DanSheps DanSheps added type: bug A confirmed report of unexpected behavior in the application severity: medium Results in substantial degraded or broken functionality for specfic workflows status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation labels Apr 23, 2025
@DanSheps
Copy link
Member

DanSheps commented 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 DanSheps 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 Apr 23, 2025
@DanSheps DanSheps self-assigned this Apr 23, 2025
@DanSheps
Copy link
Member

DanSheps commented 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>
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
3 participants