Duke-GCB / D4S2

Web service to facilitate notification and transfer of projects in DukeDS
MIT License
0 stars 0 forks source link

500 error when the wrong user tries to accept a delivery #223

Closed johnbradley closed 4 years ago

johnbradley commented 4 years ago

When an unaffiliated user opens the URL to accept a delivery a 500 error occurs. Example stack trace from the server:

ERROR:django.request:Internal Server Error: /ownership/
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/app/ownership/views.py", line 138, in get
    return self._action(request, self.handle_get)
  File "/app/ownership/views.py", line 130, in _action
    self._prepare(request)
  File "/app/ownership/views.py", line 46, in _prepare
    self.context = self.get_context_data()
  File "/app/ownership/views.py", line 62, in get_context_data
    context.update(details.get_context())
  File "/app/switchboard/dds_util.py", line 383, in get_context
    project = self.get_project()
  File "/app/switchboard/dds_util.py", line 336, in get_project
    transfer = DDSProjectTransfer.fetch_one(self.ddsutil, transfer_id)
  File "/app/switchboard/dds_util.py", line 303, in fetch_one
    response = dds_util.get_project_transfer(dds_project_transfer_id).json()
  File "/app/switchboard/dds_util.py", line 66, in get_project_transfer
    return self.remote_store.data_service.get_project_transfer(transfer_id)
  File "/usr/local/lib/python3.6/site-packages/ddsc/core/ddsapi.py", line 757, in get_project_transfer
    return self._get_single_item("/project_transfers/" + transfer_id, {})
  File "/usr/local/lib/python3.6/site-packages/ddsc/core/ddsapi.py", line 41, in retry_function
    result = func(*args, **kwds)
  File "/usr/local/lib/python3.6/site-packages/ddsc/core/ddsapi.py", line 280, in _get_single_item
    return self._check_err(resp, url_suffix, data, allow_pagination=False)
  File "/usr/local/lib/python3.6/site-packages/ddsc/core/ddsapi.py", line 353, in _check_err
    raise DataServiceError(resp, url_suffix, data)
ddsc.core.ddsapi.DataServiceError: Error 403 on /project_transfers/...
Reason:Unauthorized
Suggestion:request permission to access this resource

When this happens the user should get an appropriate warning not a 500 error.