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

[bug] 500 internal server error for NoReverse match #682

Open
nemesifier opened this issue Jul 19, 2022 · 0 comments · May be fixed by #938
Open

[bug] 500 internal server error for NoReverse match #682

nemesifier opened this issue Jul 19, 2022 · 0 comments · May be fixed by #938
Labels

Comments

@nemesifier
Copy link
Member

Related to #681 (happens while testing that bug).

Try opening http://localhost:8000/admin/config/device/de8fa775-1134-47b6-adc5-2da3d0626c72/history/1564/undefinedadmin/img/icon-deletelink.svg.

Expected result: 404 not found
Actual result: 500 internal server error

NoReverseMatch: Reverse for 'config_template_download' with arguments '('de8fa775-1134-47b6-adc5-2da3d0626c72/history/1564/undefinedadmin/img/icon-deletelink.svg',)' not found. 1 pattern(s) tried: ['admin/config/template/download/(?P<pk>[^/]+)/$']
  File "django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/contrib/admin/options.py", line 683, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "django/utils/decorators.py", line 133, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "django/contrib/admin/sites.py", line 242, in inner
    return view(request, *args, **kwargs)
  File "openwisp_controller/config/admin.py", line 133, in change_view
    extra_context = self.get_extra_context(object_id)
  File "openwisp_controller/config/admin.py", line 110, in get_extra_context
    ctx['download_url'] = reverse('{0}_download'.format(prefix), args=[pk])
  File "django/urls/base.py", line 88, in reverse
    return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
  File "django/urls/resolvers.py", line 802, in _reverse_with_prefix
    raise NoReverseMatch(msg)

It looks like the URL pattern for this route is not strict enough.

The same happens with Template and VPN.

I think this is probably happening for all the url patterns, we should change the pattern and only allow letters, numbers and dashes, nothing more. The re_path must be kept for backward compatibility reasons (devices send the UUID without dashes and that is not recognized by Django's normal path functions).

@nemesifier nemesifier added the bug label Jul 19, 2022
@nemesifier nemesifier moved this to To do (Python & Django) in OpenWISP Contributor's Board Aug 21, 2024
chahatsagarmain added a commit to chahatsagarmain/openwisp-controller that referenced this issue Nov 6, 2024
Changed regex for uuid pattern and uuid pattern check in admin.py

Fixes openwisp#682

Signed-off-by: chahatsagarmain <[email protected]>
chahatsagarmain added a commit to chahatsagarmain/openwisp-controller that referenced this issue Nov 6, 2024
Changed regex for uuid pattern and uuid pattern check in admin.py

Fixes openwisp#682

Signed-off-by: chahatsagarmain <[email protected]>
@chahatsagarmain chahatsagarmain linked a pull request Nov 6, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To do (Python & Django)
Development

Successfully merging a pull request may close this issue.

1 participant