Editing profile without avatar returns 500 #65573

Closed
opened 2019-06-06 17:21:52 +02:00 by Francesco Siddi · 3 comments

When editing a profile without avatar, we get internal server error. From a quick look at bid_main/forms.py, I see that:

    def clean_avatar(self):
        data = self.cleaned_data['avatar']
        if isinstance(data, bool):
            # This happens when the user checks the 'clean' checkbox.
            return data

        filename = pathlib.PurePath(data.name)

If data is Null, then we crash and burn. Simply checking for null data could solve the issue?

Full error stack:

Traceback (most recent call last):
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/contrib/auth/mixins.py", line 52, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/base.py", line 97, in dispatch
    return handler(request, *args, **kwargs)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/edit.py", line 194, in post
    return super().post(request, *args, **kwargs)
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/edit.py", line 141, in post
    if form.is_valid():
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 185, in is_valid
    return self.is_bound and not self.errors
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 180, in errors
    self.full_clean()
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 381, in full_clean
    self._clean_fields()
  File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 402, in _clean_fields
    value = getattr(self, 'clean_%s' % name)()
  File "./bid_main/forms.py", line 117, in clean_avatar
    filename = pathlib.PurePath(data.name)
When editing a profile without avatar, we get internal server error. From a quick look at `bid_main/forms.py`, I see that: ``` def clean_avatar(self): data = self.cleaned_data['avatar'] if isinstance(data, bool): # This happens when the user checks the 'clean' checkbox. return data filename = pathlib.PurePath(data.name) ``` If data is Null, then we crash and burn. Simply checking for null data could solve the issue? Full error stack: ``` Traceback (most recent call last): File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view return self.dispatch(request, *args, **kwargs) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/contrib/auth/mixins.py", line 52, in dispatch return super().dispatch(request, *args, **kwargs) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/base.py", line 97, in dispatch return handler(request, *args, **kwargs) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/edit.py", line 194, in post return super().post(request, *args, **kwargs) File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/views/generic/edit.py", line 141, in post if form.is_valid(): File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 185, in is_valid return self.is_bound and not self.errors File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 180, in errors self.full_clean() File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 381, in full_clean self._clean_fields() File "/var/www/blender-id/.venv/lib/python3.6/site-packages/django/forms/forms.py", line 402, in _clean_fields value = getattr(self, 'clean_%s' % name)() File "./bid_main/forms.py", line 117, in clean_avatar filename = pathlib.PurePath(data.name) ```
Sybren A. Stüvel was assigned by Francesco Siddi 2019-06-06 17:21:52 +02:00
Author
Owner

Added subscribers: @fsiddi, @jesterking

Added subscribers: @fsiddi, @jesterking

This issue was referenced by d53aab37b5

This issue was referenced by d53aab37b59335ac1de77f1329b7493576c21f1b

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: infrastructure/blender-id#65573
No description provided.