KeyError exception when required metadata is missing
I'm using mayan v4.0.4. Trying to add a document where a required metadata is missing leads to a KeyError exception.
To reproduce:
- Create metadata type and document type using the metadata as "required".
- Create new document but leave the required metadata empty
Expected behavior: The form should remind the user to fill in the required metadata.
Actual behavior:
Server error
There's been an unexpected error.
In the logs:
Traceback (most recent call last):
File "/opt/mayan-edms/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/sources/wizards.py", line 59, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/formtools/wizard/views.py", line 244, in dispatch
response = super().dispatch(request, *args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
return handler(request, *args, **kwargs)
File "/opt/mayan-edms/lib/python3.7/site-packages/formtools/wizard/views.py", line 294, in post
if form.is_valid():
File "/opt/mayan-edms/lib/python3.7/site-packages/django/forms/formsets.py", line 301, in is_valid
self.errors
File "/opt/mayan-edms/lib/python3.7/site-packages/django/forms/formsets.py", line 281, in errors
self.full_clean()
File "/opt/mayan-edms/lib/python3.7/site-packages/django/forms/formsets.py", line 329, in full_clean
form_errors = form.errors
File "/opt/mayan-edms/lib/python3.7/site-packages/django/forms/forms.py", line 180, in errors
self.full_clean()
File "/opt/mayan-edms/lib/python3.7/site-packages/django/forms/forms.py", line 382, in full_clean
self._clean_form()
File "/opt/mayan-edms/lib/python3.7/site-packages/django/forms/forms.py", line 409, in _clean_form
cleaned_data = self.clean()
File "/opt/mayan-edms/lib/python3.7/site-packages/mayan/apps/metadata/forms.py", line 104, in clean
if required and not self.cleaned_data['value'] and not self.cleaned_data.get('update'):
KeyError: 'value'