Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository: Edit Metadata page may not load due to KeyError #4585

Open
joemull opened this issue Jan 20, 2025 · 0 comments · May be fixed by #4586
Open

Repository: Edit Metadata page may not load due to KeyError #4585

joemull opened this issue Jan 20, 2025 · 0 comments · May be fixed by #4586
Assignees
Labels
bug Something's not working priority-high High priority size XS Extra small

Comments

@joemull
Copy link
Member

joemull commented Jan 20, 2025

Describe the bug

There is a chance of a KeyError here:

if self.instance:
self.fields['submission_agreement'].initial = True

Internal Server Error: /elr/repository/manager/3/edit/metadata/
Traceback (most recent call last):
  File "/home/joemull/git/janedb/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/joemull/git/janedb/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joemull/git/janedb/src/security/decorators.py", line 72, in wrapper
    return func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joemull/git/janedb/src/security/decorators.py", line 1245, in wrapper
    return func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/joemull/git/janedb/src/repository/views.py", line 1027, in repository_edit_metadata
    metadata_form = forms.PreprintInfo(
                    ^^^^^^^^^^^^^^^^^^^
  File "/home/joemull/git/janedb/src/repository/forms.py", line 63, in __init__
    self.fields['submission_agreement'].initial = True
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'submission_agreement'

Janeway version
1.7.0

Proposed solution
Check for the existence of the field, as it could have been popped off right above.

@joemull joemull added the bug Something's not working label Jan 20, 2025
joemull added a commit that referenced this issue Jan 20, 2025
@joemull joemull self-assigned this Jan 20, 2025
@joemull joemull added size XS Extra small priority-high High priority labels Jan 20, 2025
@joemull joemull changed the title Preprint info page may not load due to KeyError Repository: Edit Metadata page may not load due to KeyError Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something's not working priority-high High priority size XS Extra small
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant