PuzzleTechHub / myus

A public hassle free puzzlehunt hosting tool
https://www.puzzlehuntmy.us/
MIT License
1 stars 9 forks source link

500 error when creating new hunt #38

Closed TheOriginalSoni closed 4 months ago

TheOriginalSoni commented 4 months ago

When a new hunt is created, everything works as expected, EXCEPT this error is thrown at the very end.

The hunt is still created as expected, it's just not displayed well. So must be a problem with the display somewhere at /new

 2024-02-19 11:42:39,269 (PID 7) [ERROR] log
2024-02-19T11:42:39.270483+00:00 app[web.1]: Internal Server Error: /new
2024-02-19T11:42:39.270485+00:00 app[web.1]: Traceback (most recent call last):
2024-02-19T11:42:39.270485+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
2024-02-19T11:42:39.270486+00:00 app[web.1]: response = get_response(request)
2024-02-19T11:42:39.270486+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
2024-02-19T11:42:39.270486+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2024-02-19T11:42:39.270487+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
2024-02-19T11:42:39.270487+00:00 app[web.1]: return view_func(request, *args, **kwargs)
2024-02-19T11:42:39.270487+00:00 app[web.1]: File "/app/myus/myus/views.py", line 121, in new_hunt
2024-02-19T11:42:39.270488+00:00 app[web.1]: return redirect(urls.reverse("view_hunt", args=[hunt.slug]))
2024-02-19T11:42:39.270488+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/urls/base.py", line 88, in reverse
2024-02-19T11:42:39.270488+00:00 app[web.1]: return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
2024-02-19T11:42:39.270489+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.10/site-packages/django/urls/resolvers.py", line 851, in _reverse_with_prefix
2024-02-19T11:42:39.270489+00:00 app[web.1]: raise NoReverseMatch(msg)
2024-02-19T11:42:39.270499+00:00 app[web.1]: django.urls.exceptions.NoReverseMatch: Reverse for 'view_hunt' with arguments '('test-6',)' not found. 2 pattern(s) tried: ['hunt/(?P<hunt_id>[0-9]+)\\-(?P<slug>[-a-zA-Z0-9_]+)\\Z', 'hunt/(?P<hunt_id>[0-9]+)\\Z']
TheOriginalSoni commented 4 months ago

Most definitely introduced somewhere in #34 while resolving #5

Should be a simple fix though

TheOriginalSoni commented 4 months ago

Fixed at 2f35403 thanks to DLareau

TheOriginalSoni commented 4 months ago

Alternate way of solving, and other comments from Discord.

kwargs={"slug":hunt.slug, "hunt_id":hunt.pk} but really the only thing you gain with kwargs is resiliency against people changing the URL parameter ordering.

(For args it must be specifically in id/pk then slug ordering)