openlibhums / janeway

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

Repository & repository manager dashboard cannot load if preprint owner/authors aren't connected to accounts #3134

Open alainna opened 2 years ago

alainna commented 2 years ago

Describe the bug The repository & repository manager dashboard display Server Errors if one or more preprint owner/authors aren't connected to accounts.

Janeway version 1.4.2.1 Preprints

To Reproduce Steps to reproduce the behavior:

  1. Create a preprint whose owner and author do not have accounts in the system.
  2. Access repository manager dashboard /repository/manager
  3. See error
  4. Compare: Access repository manager item view /repository/manager/XXXX/
  5. See item metadata & management commands sans issue.
  6. Access repository public view: /
  7. See error
  8. Compare: Access public item view /repository/view/XXXX/
  9. See public item sans issue.

Expected behavior Repository manager dashboard loads sans issue, similar to item view. Repository loads sans issue, similar to item view

Screenshots image

image

Additional context We experienced this issue when using our old import script from before the preprint author rework.

From Sentry:

TypeError: 'PreprintAuthor' object is not subscriptable
  File "django/template/base.py", line 882, in _resolve_lookup
    current = current[bit]
AttributeError: 'NoneType' object has no attribute 'middle_name'
  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "security/decorators.py", line 64, in wrapper
    return func(request, *args, **kwargs)
  File "security/decorators.py", line 1094, in preprint_manager_wrapper
    return func(request, *args, **kwargs)
  File "repository/views.py", line 836, in preprints_manager
    return render(request, template, context)
  File "django/shortcuts.py", line 30, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "django/template/loader.py", line 68, in render_to_string
    return template.render(context, request)
  File "django/template/backends/django.py", line 66, in render
    return self.template.render(context)
  File "django/template/base.py", line 207, in render
    return self._render(context)
  File "django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 177, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 199, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 72, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 990, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "django/template/defaulttags.py", line 216, in render
    nodelist.append(node.render_annotated(context))
  File "django/template/base.py", line 957, in render_annotated
    return self.render(context)
  File "django/template/base.py", line 1040, in render
    output = self.filter_expression.resolve(context)
  File "django/template/base.py", line 708, in resolve
    obj = self.var.resolve(context)
  File "django/template/base.py", line 849, in resolve
    value = self._resolve_lookup(context)
  File "django/template/base.py", line 890, in _resolve_lookup
    current = getattr(current, bit)
  File "repository/models.py", line 814, in full_name
    if not self.account.middle_name:
ajrbyers commented 2 years ago

@alainna i think the script needs to be updated to use the new models… we can fix this issue but you should still update it.

alainna commented 2 years ago

Yes, we're already on that -- just wanted to share some context on how we found the issue. 😉