Should guard better for user metadata being malformed/missing? #1085
Closed
Description
Trying to get a local instance of API server + web UI for development.
I have DJANGO logged in in /swagger
under my email/password. Tried to authorize and get a token but
I went to /admin
interface and added first and last name for my record in Users.
and then now when I go to web UI at http://localhost:8085/ I get "Connection to server failed." and following traceback in console
$> [15:34:50] INFO "GET /api/info/ HTTP/1.1" 200 344 basehttp.py:187
ERROR Internal Server Error: /api/users/me/ log.py:241
Traceback (most recent call last):
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/django/core/handlers/exception.py",
line 55, in inner
response = get_response(request)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/django/core/handlers/base.py", line
197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/django/views/decorators/csrf.py", line
54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/django/views/generic/base.py", line
84, in view
return self.dispatch(request, *args, **kwargs)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/rest_framework/views.py", line 509, in
dispatch
response = self.handle_exception(exc)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/rest_framework/views.py", line 469, in
handle_exception
self.raise_uncaught_exception(exc)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/rest_framework/views.py", line 480, in
raise_uncaught_exception
raise exc
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/rest_framework/views.py", line 506, in
dispatch
response = handler(request, *args, **kwargs)
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/rest_framework/decorators.py", line
50, in handler
return func(*args, **kwargs)
File "/home/yoh/proj/dandi/dandi-archive/dandiapi/api/views/users.py", line 67, in users_me_view
user_dict = user_to_dict(request.user)
File "/home/yoh/proj/dandi/dandi-archive/dandiapi/api/views/users.py", line 29, in user_to_dict
'status': user.metadata.status,
File "/home/yoh/proj/dandi/dandi-archive/venvs/dev3/lib/python3.9/site-packages/django/db/models/fields/related_descri
ptors.py", line 461, in __get__
raise self.RelatedObjectDoesNotExist(
django.contrib.auth.models.User.metadata.RelatedObjectDoesNotExist: User has no metadata.
ERROR "GET /api/users/me/ HTTP/1.1" 500 133940
suggesting that something about my user freaks server out. Confirmed by going to http://localhost:8000/api/users/me/ in the browser directly.
I think regardless of the problem with the user, server must not 500