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

User.DoesNotExist error in files API #3175

Closed
hackdna opened this issue Jan 16, 2019 · 9 comments
Closed

User.DoesNotExist error in files API #3175

hackdna opened this issue Jan 16, 2019 · 9 comments

Comments

@hackdna
Copy link
Member

hackdna commented Jan 16, 2019

  • Specific code commit: dbb1848
  • Version of the web browser and OS: Chrome 71 on OS X 10.14.2
  • Environment where the error occurred: AWS and Vagrant

Steps to reproduce

  1. Deploy on AWS without specifying EBS and RDS snapshot IDs or provision a Vagrant VM from scratch
  2. Open the home page in a web browser

Observed behavior

Refinery error log:

Internal Server Error: /api/v2/files/
Traceback (most recent call last):
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch
    response = self.handle_exception(exc)
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch
    response = handler(request, *args, **kwargs)
  File "/srv/refinery-platform/refinery/user_files_manager/views.py", line 74, in get
    solr_response = _get_solr(request.query_params, request.user.id)
  File "/srv/refinery-platform/refinery/user_files_manager/views.py", line 83, in _get_solr
    user_id=user_id)
  File "/srv/refinery-platform/refinery/user_files_manager/utils.py", line 30, in generate_solr_params_for_user
    user = User.get_anonymous()
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/guardian/__init__.py", line 26, in <lambda>
    setattr(User, 'get_anonymous', staticmethod(lambda: get_anonymous_user()))
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/guardian/utils.py", line 38, in get_anonymous_user
    return User.objects.get(**lookup)
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/ubuntu/.virtualenvs/refinery-platform/lib/python2.7/site-packages/django/db/models/query.py", line 334, in get
    self.model._meta.object_name
DoesNotExist: User matching query does not exist.

Request repr():
<WSGIRequest
path:/api/v2/files/,
GET:<QueryDict: {u'sort': [u''], u'limit': [u'100'], u'filter_attribute': [u'{}']}>,
POST:<QueryDict: {}>,
COOKIES:{},
META:{'CONTEXT_DOCUMENT_ROOT': '/var/www',
'CONTEXT_PREFIX': '',
u'CSRF_COOKIE': <redacted>,
'DOCUMENT_ROOT': '/var/www',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'application/json, text/plain, */*',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate, br',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.9',
'HTTP_CONNECTION': 'keep-alive',
'HTTP_DNT': '1',
'HTTP_HOST': 'dev.stemcellcommons.org',
'HTTP_REFERER': 'https://dev.stemcellcommons.org/',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
'HTTP_X_FORWARDED_FOR': '134.174.183.128',
'HTTP_X_FORWARDED_PORT': '443',
'HTTP_X_FORWARDED_PROTO': 'https',
'PATH_INFO': u'/api/v2/files/',
'PATH_TRANSLATED': '/srv/refinery-platform/refinery/config/wsgi_aws.py/api/v2/files/',
'QUERY_STRING': 'filter_attribute=%7B%7D&limit=100&sort=',
'REMOTE_ADDR': '172.25.0.131',
'REMOTE_PORT': '55212',
'REQUEST_METHOD': 'GET',
'REQUEST_SCHEME': 'http',
'REQUEST_URI': '/api/v2/files/?filter_attribute=%7B%7D&limit=100&sort=',
'SCRIPT_FILENAME': '/srv/refinery-platform/refinery/config/wsgi_aws.py',
'SCRIPT_NAME': u'',
'SCRIPT_URI': 'http://dev.stemcellcommons.org/api/v2/files/',
'SCRIPT_URL': '/api/v2/files/',
'SERVER_ADDR': '172.25.0.218',
'SERVER_ADMIN': '[no address given]',
'SERVER_NAME': 'dev.stemcellcommons.org',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '',
'SERVER_SOFTWARE': 'Apache/2.4.7 (Ubuntu)',
'mod_wsgi.application_group': 'dev.stemcellcommons.org|',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.enable_sendfile': '0',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80',
'mod_wsgi.process_group': 'refinery',
'mod_wsgi.queue_start': '1547673199613305',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 4),
'wsgi.errors': <mod_wsgi.Log object at 0x7fa7e04a1cb0>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7fa7e0489378>,
'wsgi.input': <mod_wsgi.Input object at 0x7fa7e052adf0>,
'wsgi.multiprocess': False,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>

Expected behavior

No error

@jkmarx
Copy link
Member

jkmarx commented Feb 4, 2019

I've been able to reproduce once with a clean instance but the error does not linger on a refresh and I couldn't reproduce on subsequent tries (with fresh vm). Not a solr issue but grabbing the anonymous user in a wrapper function for user_files. I didn't see any issues in the UI.

@jkmarx jkmarx removed the solr label Feb 4, 2019
@hackdna hackdna changed the title DoesNotExist error in generate_solr_params_for_user User.DoesNotExist error in files API Mar 26, 2019
@hackdna
Copy link
Member Author

hackdna commented Mar 29, 2019

I was able to reproduce this repeatedly in a fresh VM running the latest develop (03c076d) by force reloading the home page (Cmd-Shift-R in Chrome).

@jkmarx
Copy link
Member

jkmarx commented Mar 29, 2019

@hackdna Are you seeing this issue locally at all?

@jkmarx jkmarx self-assigned this Mar 29, 2019
@jkmarx jkmarx modified the milestones: Next, Release 1.6.9 Mar 29, 2019
@jkmarx
Copy link
Member

jkmarx commented Mar 29, 2019

Can you confirm you're not logged in?

@hackdna
Copy link
Member Author

hackdna commented Mar 29, 2019

Yes: locally when not logged in.

@jkmarx
Copy link
Member

jkmarx commented Mar 29, 2019

@hackdna Do you have any data sets loaded?

@hackdna
Copy link
Member Author

hackdna commented Mar 29, 2019

No, just like it's described in steps to reproduce above.

@jkmarx
Copy link
Member

jkmarx commented Apr 3, 2019

Anon User is no longer being generated.
Screen Shot 2019-04-03 at 12 55 01 PM

@jkmarx
Copy link
Member

jkmarx commented Apr 3, 2019

@hackdna
"Once project is configured to work with django-guardian, calling syncdb management command would create User instance for anonymous user support (with name of AnonymousUser)." https://django-guardian.readthedocs.io/en/stable/configuration.html?highlight=anon

Running fab vm update resolves the issue. I'll add an error handler when the anonymous user isn't available for user/files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants