wger
wger copied to clipboard
Cannot start wger server on a leap day
This is an issue found with the docker image, however this bug seems to originate from the code.
Steps to Reproduce
- Start wger containers / instance
Expected results: Wger server starts normally
Actual results: Wger server could not start due to incorrect date constraint in Date of Birth field.
Logs
Copied from Dozzle, please excuse the timestamps.
29/02/2024
10:11:08
During handling of the above exception, another exception occurred:
29/02/2024
10:11:08
29/02/2024
10:11:08
Traceback (most recent call last):
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/sync.py", line 135, in handle
29/02/2024
10:11:08
self.handle_request(listener, req, client, addr)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/gunicorn/workers/sync.py", line 178, in handle_request
29/02/2024
10:11:08
respiter = self.wsgi(environ, resp.start_response)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/wsgi.py", line 124, in __call__
29/02/2024
10:11:08
response = self.get_response(request)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 140, in get_response
29/02/2024
10:11:08
response = self._middleware_chain(request)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 57, in inner
29/02/2024
10:11:08
response = response_for_exception(request, exc)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 140, in response_for_exception
29/02/2024
10:11:08
response = handle_uncaught_exception(
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 181, in handle_uncaught_exception
29/02/2024
10:11:08
return debug.technical_500_response(request, *exc_info)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/views/debug.py", line 67, in technical_500_response
29/02/2024
10:11:08
html = reporter.get_traceback_html()
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/views/debug.py", line 410, in get_traceback_html
29/02/2024
10:11:08
c = Context(self.get_traceback_data(), use_l10n=False)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/views/debug.py", line 393, in get_traceback_data
29/02/2024
10:11:08
c["raising_view_name"] = get_caller(self.request)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/views/debug.py", line 100, in get_caller
29/02/2024
10:11:08
resolver_match = resolve(request.path)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/urls/base.py", line 24, in resolve
29/02/2024
10:11:08
return get_resolver(urlconf).resolve(path)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/urls/resolvers.py", line 663, in resolve
29/02/2024
10:11:08
for pattern in self.url_patterns:
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/utils/functional.py", line 57, in __get__
29/02/2024
10:11:08
res = instance.__dict__[self.name] = self.func(instance)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/urls/resolvers.py", line 715, in url_patterns
29/02/2024
10:11:08
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/utils/functional.py", line 57, in __get__
29/02/2024
10:11:08
res = instance.__dict__[self.name] = self.func(instance)
29/02/2024
10:11:08
File "/usr/local/lib/python3.10/dist-packages/django/urls/resolvers.py", line 708, in urlconf_module
29/02/2024
10:11:08
return import_module(self.urlconf_name)
29/02/2024
10:11:08
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
29/02/2024
10:11:08
return _bootstrap._gcd_import(name[level:], package, level)
29/02/2024
10:11:08
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
29/02/2024
10:11:08
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
29/02/2024
10:11:08
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
29/02/2024
10:11:08
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
29/02/2024
10:11:08
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
29/02/2024
10:11:08
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
29/02/2024
10:11:08
File "/home/wger/src/wger/urls.py", line 44, in <module>
29/02/2024
10:11:08
from wger.core.api import views as core_api_views
29/02/2024
10:11:08
File "/home/wger/src/wger/core/api/views.py", line 67, in <module>
29/02/2024
10:11:08
from wger.core.forms import UserLoginForm
29/02/2024
10:11:08
File "/home/wger/src/wger/core/forms.py", line 107, in <module>
29/02/2024
10:11:08
class UserPreferencesForm(forms.ModelForm):
29/02/2024
10:11:08
File "/home/wger/src/wger/core/forms.py", line 121, in UserPreferencesForm
29/02/2024
10:11:08
'max': str(date.today().replace(year=date.today().year - 10)),
29/02/2024
10:11:08
ValueError: day is out of range for month
our first leap year bug 😅
But I see what's happening, 10 years ago wasn't a leap year, so the error is valid. But also the max and min dates are set during startup and not dynamically which in this case is alright, but not very clean
our first leap year bug 😅
But I see what's happening, 10 years ago wasn't a leap year, so the error is valid. But also the max and min dates are set during startup and not dynamically which in this case is alright, but not very clean
Wouldn't that make it increasingly harder each year to set a date of birth? (Of course, only if you'd never stop the server, which isn't very likely).