elixir-cloud-aai / trs-filer

Lightweight, flexible Flask/Gunicorn-based GA4GH TRS implementation
Apache License 2.0
8 stars 6 forks source link

Deleting tool version returns Internal Server Error #79

Closed uniqueg closed 4 years ago

uniqueg commented 4 years ago

When registering a tool with multiple versions, trying to delete one version throws an InternalServerError:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/decorator.py", line 48, in wrapper
    response = function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/uri_parsing.py", line 144, in wrapper
    response = function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/validation.py", line 384, in wrapper
    return function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/response.py", line 103, in wrapper
    response = function(request)
  File "/usr/local/lib/python3.6/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
    return function(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/foca/utils/logging.py", line 61, in wrapper
    response = fn(*args, **kwargs)
  File "/app/trs_filer/ga4gh/trs/server.py", line 666, in deleteToolVersion
    raise InternalServerError
werkzeug.exceptions.InternalServerError: 500 Internal Server Error: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. [foca.errors.exceptions]

The respective code is:

    if (
        del_ver_tools.modified_count and
        del_ver_files.modified_count
    ):
        return version_id
    else:
        raise InternalServerError

As the version is afterwards missing when requesting it via, e.g., GET /tools/{id}/versions/{version_id} (returns 404/NotFound), presumably deleting the version from the files collection errors.

uniqueg commented 4 years ago

This only happens if no files have been attached to the registered tool.