EVE-University / aa-membertools

Reworked version of hrappsnext resolving hard connection issues to ESI tokens.
GNU General Public License v2.0
0 stars 0 forks source link

Handle or prevent duplicate member record generation better #7

Open marnvermuldir opened 6 months ago

marnvermuldir commented 6 months ago

Bug Description

Main tracking for members doesn't always follow the main properly especially when people switch AA accounts their character is attached to. This becomes especially complicated if someone submits applications with multiple user/main identities before merging them into a single AA user.

When this bug is in place any applications submitted by the affected user will result in a MultipleObjectsReturned exception on any accept/reject/withdraw actions.

Steps to Reproduce

Steps to reproduce the behavior: Unclear exact steps to reproduce. Needs further analysis.

Expected behavior

Action buttons should work because there aren't multiple member records matching one character.

Please complete the following information:

Additional context

Ideally we should make the member tracking code more robust to prevent multiples from being generated in the first place, and should handle merging of members when they occur due to multiple AA accounts with applications being merged into one by the user hitting Add Character to pull characters into another account.

The aim should be to handle all of this in the database hooks and keep it out of the action buttons if practical. Though application submission is another possible location we could aim to do merges if needed.

Example exception

MultipleObjectsReturned at /sad/action/approve/9410
get() returned more than one Member -- it returned 2!
Request Method:    POST
Request URL:    http://auth.eveuniversity.org/sad/action/approve/9410
Django Version:    4.0.10
Exception Type:    MultipleObjectsReturned
Exception Value:
get() returned more than one Member -- it returned 2!
Exception Location:    /opt/venv/lib/python3.9/site-packages/django/db/models/query.py, line 499, in get
Python Executable:    /opt/venv/bin/python3
Python Version:    3.9.18
Python Path:
['/home/allianceauth/myauth',
 '/home/allianceauth/myauth',
 '/opt/venv/bin',
 '/usr/local/lib/python39.zip',
 '/usr/local/lib/python3.9',
 '/usr/local/lib/python3.9/lib-dynload',
 '/opt/venv/lib/python3.9/site-packages']
Server time:    Tue, 16 Apr 2024 15:03:20 +0000
Traceback Switch to copy-and-paste view
/opt/venv/lib/python3.9/site-packages/django/core/handlers/exception.py, line 56, in inner
                response = get_response(request) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/core/handlers/base.py, line 197, in _get_response
                response = wrapped_callback(request, callback_args, **callback_kwargs) …
Local vars
/opt/venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py, line 23, in _wrapped_view
                return view_func(request,args, **kwargs)