UEWBot / dipvis

Django-based visualiser for tournaments for the boardgame Diplomacy
GNU General Public License v3.0
7 stars 5 forks source link

Invalid dates in WDD cause an exception #99

Closed UEWBot closed 4 years ago

UEWBot commented 4 years ago

On http://world-diplomacy-database.com/php/results/player_fiche5.php?id_player=13317, the "Netherlands Diplomacy Championship 2017" has a date of "2017-09-0". This causes an exception in tournament/player.py where we try to save the PlayerTournamentRanking, because it is not a valid date. django.core.exceptions.ValidationError: ["'2017-09-0' value has the correct format (YYYY-MM-DD) but it is an invalid date."] We catch that exception, but then we still get another follow-on exception.

Traceback: Environment:

Request Method: POST Request URL: https://diplomacytv.com/admin/tournament/player/112/change/

Django Version: 2.1.2 Python Version: 3.5.2 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.humanize', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'tournament', 'django_extensions', 'cachalot') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/options.py" in wrapper

  1. return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view

  1. response = view_func(request, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func

  1. response = view_func(request, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/sites.py" in inner

  1. return view(request, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/options.py" in change_view

  1. return self.changeform_view(request, object_id, form_url, extra_context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper

  1. return bound_method(*args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view

  1. response = view_func(request, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/options.py" in changeform_view

  1. return self._changeform_view(request, object_id, form_url, extra_context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/options.py" in _changeform_view

  1. self.log_change(request, new_object, change_message)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/options.py" in log_change

  1. change_message=message,

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/contrib/admin/models.py" in log_action

  1. change_message=change_message,

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method

  1. return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/query.py" in create

  1. obj.save(force_insert=True, using=self.db)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/base.py" in save

  1. force_update=force_update, update_fields=update_fields)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/base.py" in save_base

  1. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/base.py" in _save_table

  1. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/base.py" in _do_insert

  1. using=using, raw=raw)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method

  1. return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/query.py" in _insert

  1. return query.get_compiler(using=using).execute_sql(return_id)

File "/home/ubuntu/.local/lib/python3.5/site-packages/cachalot/monkey_patch.py" in inner

  1. return original(compiler, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/cachalot/monkey_patch.py" in inner

  1. return original(write_compiler, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql

  1. cursor.execute(sql, params)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/backends/utils.py" in execute

  1. return super().execute(sql, params)

File "/home/ubuntu/.local/lib/python3.5/site-packages/cachalot/monkey_patch.py" in inner

  1. return original(cursor, sql, *args, **kwargs)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/backends/utils.py" in execute

  1. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute_with_wrappers

  1. return executor(sql, params, many, context)

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute

  1. self.db.validate_no_broken_transaction()

File "/home/ubuntu/.local/lib/python3.5/site-packages/django/db/backends/base/base.py" in validate_no_broken_transaction

  1. "An error occurred in the current transaction. You can't "

Exception Type: TransactionManagementError at /admin/tournament/player/112/change/ Exception Value: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.

UEWBot commented 4 years ago

Commit 571e467ae430618fc6d9b151e0f21f8882fcddfc fixes this.