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

Exception when a script name is equal to the start of the name of another one #14025

Closed
venomnom opened this issue Oct 12, 2023 · 1 comment · Fixed by #14030
Closed

Exception when a script name is equal to the start of the name of another one #14025

venomnom opened this issue Oct 12, 2023 · 1 comment · Fixed by #14030
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

Comments

@venomnom
Copy link

NetBox version

v3.6.2

Python version

3.11

Steps to Reproduce

  1. create two scripts for netbox with some sample code named test.py and testscript.py
  2. upload them to NetBox scripts
  3. try to open the test.py script

Expected Behavior

The script page should be opened

Observed Behavior

Error in website
netbox_error
and

Error in logging:
2023-10-12 13:26:02,131 django.request ERROR: Internal Server Error: /extras/scripts/test/Test/ Traceback (most recent call last): File "/opt/netbox/dev/venv/lib64/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/venv/lib64/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/venv/lib64/python3.11/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/netbox/utilities/views.py", line 53, in dispatch return super().dispatch(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/venv/lib64/python3.11/site-packages/django/views/generic/base.py", line 143, in dispatch return handler(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/netbox/extras/views.py", line 1160, in get module = get_object_or_404(ScriptModule.objects.restrict(request.user), file_path__startswith=module) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/venv/lib64/python3.11/site-packages/django/shortcuts.py", line 85, in get_object_or_404 return queryset.get(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/dev/venv/lib64/python3.11/site-packages/django/db/models/query.py", line 640, in get raise self.model.MultipleObjectsReturned( extras.models.scripts.ScriptModule.MultipleObjectsReturned: get() returned more than one ScriptModule -- it returned 2!

@venomnom venomnom added the type: bug A confirmed report of unexpected behavior in the application label Oct 12, 2023
@venomnom
Copy link
Author

I assume the problem lies in the extras/views.py files, line 1160:
module = get_object_or_404(ScriptModule.objects.restrict(request.user), file_path__startswith=module)

@arthanson arthanson self-assigned this Oct 12, 2023
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows labels Oct 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Development

Successfully merging a pull request may close this issue.

3 participants