BirkbeckCTP / janeway

A web-based platform for publishing journals, preprints, conference proceedings, and books
https://janeway.systems/
GNU Affero General Public License v3.0
165 stars 65 forks source link

uncaught MultipleObjectsReturned exception when submitting an article #4286

Open StephDriver opened 2 weeks ago

StephDriver commented 2 weeks ago

This may just be a dev error, but here goes:

Error Message

MultipleObjectsReturned at /submit/12/authors/

get() returned more than one Role -- it returned 2!
Request Method: | POST -- | -- http://localhost:8000/alpha/submit/12/authors/ 4.2.11 MultipleObjectsReturned get() returned more than one Role -- it returned 2! /Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages/django/db/models/query.py, line 640, in get submission.decorators.submission_is_enabled_wrapper /Users/stephdriver/Documents/Janeway/venv/Janeway/bin/python3 3.9.19 ['/Users/stephdriver/Documents/Janeway/janeway/src', '/opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python39.zip', '/opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9', '/opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload', '/Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages', '/Users/stephdriver/Documents/Janeway/janeway/src/plugins'] Thu, 20 Jun 2024 08:41:29 +0100 ### details https://dpaste.com/F2N2BXV9K
StephDriver commented 2 weeks ago

Traceback (most recent call last): File "/Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view return view_func(request, *args, *kwargs) File "/Users/stephdriver/Documents/Janeway/janeway/src/submission/decorators.py", line 33, in submission_is_enabled_wrapper return func(request, args, kwargs) File "/Users/stephdriver/Documents/Janeway/janeway/src/security/decorators.py", line 1371, in _article_is_not_submitted return func(request, *args, kwargs) File "/Users/stephdriver/Documents/Janeway/janeway/src/security/decorators.py", line 728, in wrapper return func(request, *args, *kwargs) File "/Users/stephdriver/Documents/Janeway/janeway/src/security/decorators.py", line 66, in wrapper return func(request, args, kwargs) File "/Users/stephdriver/Documents/Janeway/janeway/src/security/decorators.py", line 1329, in submission_authorised_wrapper return func(request, *args, *kwargs) File "/Users/stephdriver/Documents/Janeway/janeway/src/submission/views.py", line 288, in submit_authors logic.add_user_as_author(author, article) File "/Users/stephdriver/Documents/Janeway/janeway/src/submission/logic.py", line 48, in add_user_as_author user.add_account_role("author", article.journal) File "/Users/stephdriver/Documents/Janeway/janeway/src/core/models.py", line 415, in add_account_role role = Role.objects.get(slug=role_slug) File "/Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(args, **kwargs) File "/Users/stephdriver/Documents/Janeway/venv/Janeway/lib/python3.9/site-packages/django/db/models/query.py", line 640, in get raise self.model.MultipleObjectsReturned(

Exception Type: MultipleObjectsReturned at /submit/12/authors/ Exception Value: get() returned more than one Role -- it returned 2!

StephDriver commented 2 weeks ago

Also happening when I add self as author - so may not be about author choice. Triggered on add self button press.

With add (new) author, the popup is fine, but on submitting the popup with the new author info the error is triggered.

ajrbyers commented 2 weeks ago

In admin, check if you have duplicate Role values for the journal you're loading an article for. We need to add a catch for this though so keep the ticket open.

StephDriver commented 2 weeks ago

In admin, check if you have duplicate Role values for the journal you're loading an article for.

Account I was using has multiple roles (editor, reviewer etc) in that journal, but only has each of them once. No duplicates.