Cannot upload profile image in Nutmeg

Hi there,
Testing Nutmeg, I get this error when trying to upload a profile image.

2022-06-13 15:56:12,893 ERROR 7 [django.request] [user 5] [ip 10.x.x.x] - Internal Server Error: /api/user/v1/accounts/andres/image
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/", line 47, in inner
    response = get_response(request)
  File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/pyenv/versions/3.8.12/lib/python3.8/", line 75, in inner
    return func(*args, **kwds)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/decorators/", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/django/views/generic/", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 497, in dispatch
    self.initial(request, *args, **kwargs)
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 414, in initial
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 324, in perform_authentication
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 227, in user
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 380, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/openedx/venv/lib/python3.8/site-packages/edx_rest_framework_extensions/auth/jwt/", line 75, in authenticate
  File "/openedx/venv/lib/python3.8/site-packages/edx_rest_framework_extensions/auth/jwt/", line 167, in enforce_csrf
    reason = check.process_view(request, None, (), {})
  File "/openedx/venv/lib/python3.8/site-packages/django/middleware/", line 297, in process_view
    request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 431, in POST
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 279, in _load_data_and_files
    self._data, self._files = self._parse()
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 329, in _parse
    stream =
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 203, in stream
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 309, in _load_stream
    self._stream = io.BytesIO(self.body)
  File "/openedx/venv/lib/python3.8/site-packages/rest_framework/", line 416, in __getattr__
    return getattr(self._request, attr)
  File "/openedx/venv/lib/python3.8/site-packages/django/http/", line 328, in body
    raise RawPostDataException("You cannot access body after reading from request's data stream")
django.http.request.RawPostDataException: You cannot access body after reading from request's data stream
[pid: 7|app: 0|req: 18/64] 10.x.x.x () {52 vars in 3429 bytes} [Mon Jun 13 15:55:58 2022] POST /api/user/v1/accounts/andres/image => generated 9380 bytes in 15141 msecs (HTTP/1.1 500) 9 headers in 641 bytes (264 switches on core 0)

Thank you very much, Andres.

Admittedly I cannot find a test case in our test sheet for this. Therefore I will add this test case for Olive.

However, it’s working for me: Learner Profile | Open edX Demo Site

Hi Dean!
I think I’ve found something. I tried in the demo site with the same image (12MB jpg), and it failed! But then I tried with a smaller one (1MB), and it worked. Looks like it’s got to do with the size. It’s reasonable to have a limit. Maybe we can add a file size check before uploading?

Hi Andres, smart thinking. It must be file size related then.

Yes some kind of check before uploading, or maybe a useful error message? Whichever option is easier to develop/implement.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.