datopian / ckanext-versioning

Deprecated. See https://github.com/datopian/ckanext-versions. ⏰ CKAN extension providing data versioning (metadata and files) based on git and github.
https://tech.datopian.com/versioning/
GNU Affero General Public License v3.0
7 stars 4 forks source link

500 Error when there is a conflict with package ID on create #63

Open pdelboca opened 4 years ago

pdelboca commented 4 years ago

If the user tries to create a dataset with an already existing name the system will throw a 500 Internal Server Error.

Error - <class 'metastore.backend.exc.Conflict'>: Datapackage with the same ID already exists
URL: http://dataexchange-poc.gatesfoundation.org/dataset/new
File '/usr/local/lib/python2.7/dist-packages/weberror/errormiddleware.py', line 171 in __call__
  app_iter = self.application(environ, sr_checker)
File '/usr/local/lib/python2.7/dist-packages/webob/dec.py', line 147 in __call__
  resp = self.call_func(req, *args, **self.kwargs)
File '/usr/local/lib/python2.7/dist-packages/webob/dec.py', line 208 in call_func
  return self.func(req, *args, **kwargs)
File '/usr/local/lib/python2.7/dist-packages/fanstatic/publisher.py', line 234 in __call__
  return request.get_response(self.app)
File '/usr/local/lib/python2.7/dist-packages/webob/request.py', line 1053 in get_response
  application, catch_exc_info=False)
File '/usr/local/lib/python2.7/dist-packages/webob/request.py', line 1022 in call_application
  app_iter = application(self.environ, start_response)
File '/usr/local/lib/python2.7/dist-packages/webob/dec.py', line 147 in __call__
  resp = self.call_func(req, *args, **self.kwargs)
File '/usr/local/lib/python2.7/dist-packages/webob/dec.py', line 208 in call_func
  return self.func(req, *args, **kwargs)
File '/usr/local/lib/python2.7/dist-packages/fanstatic/injector.py', line 54 in __call__
  response = request.get_response(self.app)
File '/usr/local/lib/python2.7/dist-packages/webob/request.py', line 1053 in get_response
  application, catch_exc_info=False)
File '/usr/local/lib/python2.7/dist-packages/webob/request.py', line 1022 in call_application
  app_iter = application(self.environ, start_response)
File '/usr/lib/ckan/src/ckan/ckan/config/middleware/pylons_app.py', line 262 in inner
  result = application(environ, start_response)
File '/usr/local/lib/python2.7/dist-packages/beaker/middleware.py', line 73 in __call__
  return self.app(environ, start_response)
File '/usr/local/lib/python2.7/dist-packages/beaker/middleware.py', line 156 in __call__
  return self.wrap_app(environ, session_start_response)
File '/usr/local/lib/python2.7/dist-packages/routes/middleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File '/usr/lib/ckan/src/ckan/ckan/config/middleware/common_middleware.py', line 30 in __call__
  return self.app(environ, start_response)
File '/usr/lib/ckan/src/ckan/ckan/config/middleware/common_middleware.py', line 56 in __call__
  return self.app(environ, start_response)
File '/usr/local/lib/python2.7/dist-packages/pylons/wsgiapp.py', line 125 in __call__
  response = self.dispatch(controller, environ, start_response)
File '/usr/local/lib/python2.7/dist-packages/pylons/wsgiapp.py', line 324 in dispatch
  return controller(environ, start_response)
File '/usr/lib/ckan/src/ckan/ckan/lib/base.py', line 240 in __call__
  res = WSGIController.__call__(self, environ, start_response)
File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 221 in __call__
  response = self._dispatch_call()
File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 172 in _dispatch_call
  response = self._inspect_call(func)
File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File '/usr/local/lib/python2.7/dist-packages/pylons/controllers/core.py', line 60 in _perform_call
  return func(**args)
File '/usr/lib/ckan/src/ckan/ckan/controllers/package.py', line 525 in new
  return self._save_new(context, package_type=package_type)
File '/usr/lib/ckan/src/ckan/ckan/controllers/package.py', line 933 in _save_new
  pkg_dict = get_action('package_create')(context, data_dict)
File '/usr/lib/ckan/src/ckan/ckan/logic/__init__.py', line 466 in wrapped
  result = _action(context, data_dict, **kw)
File '/usr/lib/ckan/src/contrib/ckanext/ckanext-gdx/ckanext/gdx/logic/action.py', line 616 in package_create
  dataset_dict = core_package_create(context, data_dict)
File '/usr/lib/ckan/src/ckan/ckan/logic/action/create.py', line 211 in package_create
  item.after_create(context, data)
File '/usr/local/lib/python2.7/dist-packages/ckanext/versioning/plugin.py', line 119 in after_create
  author=author
File '/usr/local/lib/python2.7/dist-packages/metastore/backend/github/storage.py', line 53 in create
  raise exc.Conflict("Datapackage with the same ID already exists")
Conflict: Datapackage with the same ID already exists

The exception is being handle in metastore so we should add a wrapper into ckanext-versioning to display a proper message to the user as CKAN does.